If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
Subform controls: ARGH!
Why can't I ever remember the code?
I have a search facility with two unbound boxes on a form. One of the boxes I want to search is in a subform. This is what I have: [forms]![Queries Form]![AddressDet].[form]![address1] Is this correct? I know I have to distinguish between the name of the form and the "box" in which it sits in the main form. |
#2
|
|||
|
|||
Subform controls: ARGH!
"scubadiver" wrote in message
... Why can't I ever remember the code? I have a search facility with two unbound boxes on a form. One of the boxes I want to search is in a subform. This is what I have: [forms]![Queries Form]![AddressDet].[form]![address1] Is this correct? I know I have to distinguish between the name of the form and the "box" in which it sits in the main form. Looks correct. When in doubt use the builder. You get a nice GUI to navigate to the control in question and in return get a reference that is guaranteed to be correct. -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#3
|
|||
|
|||
Subform controls: ARGH!
I thought it was correct
I don't know whether you gathered the code is in VBA. This is the code in its entirety as I have it now: Dim rstClone As Object Set rstClone = Me.RecordsetClone rstClone.FindFirst "[CustomerName] = '" & Me.Customer & "' And [forms]![queries form]![Branch form].[form]![address1] = '" & Me.address & "'" Me.Bookmark = rstClone.Bookmark Set rstClone = Nothing End Sub Get the following message: "The microsoft jet database engine does not recognise ....[ ]....as a valid field name or expression". ???? "Rick Brandt" wrote: "scubadiver" wrote in message ... Why can't I ever remember the code? I have a search facility with two unbound boxes on a form. One of the boxes I want to search is in a subform. This is what I have: [forms]![Queries Form]![AddressDet].[form]![address1] Is this correct? I know I have to distinguish between the name of the form and the "box" in which it sits in the main form. Looks correct. When in doubt use the builder. You get a nice GUI to navigate to the control in question and in return get a reference that is guaranteed to be correct. -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#4
|
|||
|
|||
Subform controls: ARGH!
"scubadiver" wrote in message
... I thought it was correct I don't know whether you gathered the code is in VBA. This is the code in its entirety as I have it now: Dim rstClone As Object Set rstClone = Me.RecordsetClone rstClone.FindFirst "[CustomerName] = '" & Me.Customer & "' And [forms]![queries form]![Branch form].[form]![address1] = '" & Me.address & "'" Me.Bookmark = rstClone.Bookmark Set rstClone = Nothing End Sub Get the following message: "The microsoft jet database engine does not recognise ....[ ]....as a valid field name or expression". You should have the form reference outside the quotes... rstClone.FindFirst "[CustomerName] = '" & Me.Customer & "' And " & [forms]![queries form]![Branch form].[form]![address1] & " = '" & Me.address & "'" -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#5
|
|||
|
|||
Subform controls: ARGH!
I assume there is a reason for the double quotes and ampersands around the
reference? Is it because the reference is in a subform? [Forms]![Queries form]![branch form].Form![Address1] I still have the above and the message is now: "Can't find the field 'branch form' referred to in your expression". I still can't see what is going on! "Rick Brandt" wrote: "scubadiver" wrote in message ... I thought it was correct I don't know whether you gathered the code is in VBA. This is the code in its entirety as I have it now: Dim rstClone As Object Set rstClone = Me.RecordsetClone rstClone.FindFirst "[CustomerName] = '" & Me.Customer & "' And [forms]![queries form]![Branch form].[form]![address1] = '" & Me.address & "'" Me.Bookmark = rstClone.Bookmark Set rstClone = Nothing End Sub Get the following message: "The microsoft jet database engine does not recognise ....[ ]....as a valid field name or expression". You should have the form reference outside the quotes... rstClone.FindFirst "[CustomerName] = '" & Me.Customer & "' And " & [forms]![queries form]![Branch form].[form]![address1] & " = '" & Me.address & "'" -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
#6
|
|||
|
|||
Subform controls: ARGH!
The reason for the quotes and ampersands is that the reference to the
control has to be outside of the quotes so that you get its value. The FindFirst method is unable to resolve the field reference on its own. For the error you're getting, make sure that the name of the control on Queries form that holds the subform is named branch form. Depending on how you added branch form as a subform to Queries form, the name of the control may not be the same as the name of the form being used as a subform: it's the name of the control you want in that statement. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "scubadiver" wrote in message ... I assume there is a reason for the double quotes and ampersands around the reference? Is it because the reference is in a subform? [Forms]![Queries form]![branch form].Form![Address1] I still have the above and the message is now: "Can't find the field 'branch form' referred to in your expression". I still can't see what is going on! "Rick Brandt" wrote: "scubadiver" wrote in message ... I thought it was correct I don't know whether you gathered the code is in VBA. This is the code in its entirety as I have it now: Dim rstClone As Object Set rstClone = Me.RecordsetClone rstClone.FindFirst "[CustomerName] = '" & Me.Customer & "' And [forms]![queries form]![Branch form].[form]![address1] = '" & Me.address & "'" Me.Bookmark = rstClone.Bookmark Set rstClone = Nothing End Sub Get the following message: "The microsoft jet database engine does not recognise ....[ ]....as a valid field name or expression". You should have the form reference outside the quotes... rstClone.FindFirst "[CustomerName] = '" & Me.Customer & "' And " & [forms]![queries form]![Branch form].[form]![address1] & " = '" & Me.address & "'" -- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com |
Thread Tools | |
Display Modes | |
|
|