![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
How do I get a form to return to the same record after I requery. *At the moment every time I requery the form returns to the first record in the recordset. T the moment I am using: *Me.Requery |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Thankyou Patrick I've been trying that using the following code: Dim StrValue1 As String StrValue1 = [Forms]![frmPolicy]![txtPolicyNo] DoCmd.OpenForm "frmPolicy", acNormal, , , "policy_no = StrValue1" but just comes back with 'Type mismatch' |
#5
| |||
| |||
|
|
On Wed, 21 Dec 2011 05:44:43 -0800 (PST), FireyColin colin.mard... (AT) btopenworld (DOT) com> wrote: Thankyou Patrick I've been trying that using the following code: * *Dim StrValue1 As String * *StrValue1 = [Forms]![frmPolicy]![txtPolicyNo] * *DoCmd.OpenForm "frmPolicy", acNormal, , , "policy_no = StrValue1" but just comes back with 'Type mismatch' I stink at string syntax, but maybe this will work: "[policy_no] = ' " & strValue1 &" ' " -pw |
#6
| |||
| |||
|
|
On Wed, 21 Dec 2011 05:44:43 -0800 (PST), FireyColin colin.mardell (AT) btopenworld (DOT) com> wrote: Thankyou Patrick I've been trying that using the following code: Dim StrValue1 As String StrValue1 = [Forms]![frmPolicy]![txtPolicyNo] DoCmd.OpenForm "frmPolicy", acNormal, , , "policy_no = StrValue1" but just comes back with 'Type mismatch' I stink at string syntax, but maybe this will work: "[policy_no] = ' " & strValue1 &" ' " -pw |
#7
| |||
| |||
|
|
On Dec 21, 11:58*am, PW <emailaddyin... (AT) ifIremember (DOT) com> wrote: On Wed, 21 Dec 2011 05:44:43 -0800 (PST), FireyColin colin.mard... (AT) btopenworld (DOT) com> wrote: Thankyou Patrick I've been trying that using the following code: * *Dim StrValue1 As String * *StrValue1 = [Forms]![frmPolicy]![txtPolicyNo] * *DoCmd.OpenForm "frmPolicy", acNormal, , , "policy_no = StrValue1" but just comes back with 'Type mismatch' I stink at string syntax, but maybe this will work: "[policy_no] = ' " & strValue1 &" ' " -pw My rule of thumb is Strings get surrounded in qutes Dates get surrounded in # Numbers don't get surrounded So PW's response would be correct since Firey defined the value as a string |
#8
| |||
| |||
|
| "PW" <emailaddyinsig (AT) ifIremember (DOT) com> wrote in message news:8g74f7lgf2dme6glajei3f67o2ptvtmecq (AT) 4ax (DOT) com... On Wed, 21 Dec 2011 05:44:43 -0800 (PST), FireyColin colin.mardell (AT) btopenworld (DOT) com> wrote: Thankyou Patrick I've been trying that using the following code: Dim StrValue1 As String StrValue1 = [Forms]![frmPolicy]![txtPolicyNo] DoCmd.OpenForm "frmPolicy", acNormal, , , "policy_no = StrValue1" but just comes back with 'Type mismatch' I stink at string syntax, but maybe this will work: "[policy_no] = ' " & strValue1 &" ' " -pw PW's syntax should work; |
|
but why is the OP reopening the form after the requery? I find recordsetclone much more reliable. dim strValue1 as string dim rsClone as recordset StrValue1 = me.txtPolicyNo me.requery set rsClone = me.Recordsetclone rsClone.FindFirst "[PolicyNo] = '" & StrValue1 & "'" if me.nomatch then msgbox "Could not find Policy number: " & strValue1 else me.bookmark = rsClone.bookmark endif set rsclone = nothing |
#9
| |||
| |||
|
|
On Wed, 21 Dec 2011 14:05:21 -0600, "Ron Paii" <None (AT) none (DOT) com> wrote: "PW" <emailaddyinsig (AT) ifIremember (DOT) com> wrote in message news:8g74f7lgf2dme6glajei3f67o2ptvtmecq (AT) 4ax (DOT) com... On Wed, 21 Dec 2011 05:44:43 -0800 (PST), FireyColin colin.mardell (AT) btopenworld (DOT) com> wrote: Thankyou Patrick I've been trying that using the following code: Dim StrValue1 As String StrValue1 = [Forms]![frmPolicy]![txtPolicyNo] DoCmd.OpenForm "frmPolicy", acNormal, , , "policy_no = StrValue1" but just comes back with 'Type mismatch' I stink at string syntax, but maybe this will work: "[policy_no] = ' " & strValue1 &" ' " -pw PW's syntax should work; Hey - it's right out of Getz's Access 97 Handbook! :-) I wish he went into more explanation though. |
#10
| |||
| |||
|
|
My rule of thumb is Strings get surrounded in qutes Dates get surrounded in # Numbers don't get surrounded I used to have a canned response covering this somewhere. Let's see if I can |
![]() |
| Thread Tools | |
| Display Modes | |
| |