error on form1/form2 lookup

R

Raymond

Form2 is has a list box to display the desired license plate found, the forms
are bound by license tag number. text box has the after event. character
field 10.

I have a record source for form2 called visitorlog, the table.

Private Sub txtSearchReg_AfterUpdate()
Dim rs As DAO.Recordset
Dim frmAny As Form

If Len(Me.txtSearchReg & "") <> 0 Then 'Optional line
Set frmAny = Me.TEST2.Form
Set rs = frmAny.RecordsetClone
rs.FindFirst "[License Tag Number] = " & Chr(34) & Me.txtSearchReg & Chr(34)

If rs.NoMatch = False Then Me.Bookmark = rs.Bookmark

this is the line that fails
frmAny.[License Tag Number].SetFocus

DoCmd.FindRecord Me!List27, acEntire
Me.txtSearchReg = Null
End Sub
error is;
object doesn support this property or method.
Thanks
Ray
 
J

June7 via AccessMonster.com

So all of this code is behind Form2? You set variable frmAny = Me.Test2.Form
and use it only once. Why bother with the variable (the control itself serves
as variable) and think this syntax is wrong. Give an example of the selected
value from this control. Then you want to go to other form and set focus to
the control [License Tag Number]? Is the other form already open?

Suggest not using spaces or symbols or punctuation in ANY names (tables,
queries, forms, fields, controls). I always prefix control names as
indication of the type (tbxLicenseTagNumber, cbxLicenseTagNumber,
lbxLicenseTagNumber). Also clarifies that I am referring to a control and not
a record field.
Form2 is has a list box to display the desired license plate found, the forms
are bound by license tag number. text box has the after event. character
field 10.

I have a record source for form2 called visitorlog, the table.

Private Sub txtSearchReg_AfterUpdate()
Dim rs As DAO.Recordset
Dim frmAny As Form

If Len(Me.txtSearchReg & "") <> 0 Then 'Optional line
Set frmAny = Me.TEST2.Form
Set rs = frmAny.RecordsetClone
rs.FindFirst "[License Tag Number] = " & Chr(34) & Me.txtSearchReg & Chr(34)

If rs.NoMatch = False Then Me.Bookmark = rs.Bookmark

this is the line that fails
frmAny.[License Tag Number].SetFocus

DoCmd.FindRecord Me!List27, acEntire
Me.txtSearchReg = Null
End Sub
error is;
object doesn support this property or method.
Thanks
Ray
 
R

Raymond

the only code I have is on form1, txtSearchReg after event
form2 is on form1, form2 has a list box, and is a continusous form.
The code was

Private Sub txtSearchReg_AfterUpdate()
Dim rs As DAO.Recordset
Dim frmAny as Form

Set frmAny = Me.NameOfSubFormControl.Form
Set rs = frmAny.RecordsetClone
rs.FindFirst "[License_Tag_Number] = " & Me.txtSearchReg
If rs.NoMatch = False then Me.Bookmark = rs.Bookmark
frmAny.License_Tag_Number.SetFocus
Me.txtSearchReg = Null
End Sub

I did not know what to put in for 'name of sub form control' so I assumed it
meant the name of the list box, list27, that failed so I put test2, the name
of the subform.
then the next failure came...
 
R

Raymond

the txtSearchreg and list27 box are both unbound...source for both forms is
visitorlog table, order by license tag number, linked by license tag number
Ray J


June7 via AccessMonster.com said:
So all of this code is behind Form2? You set variable frmAny = Me.Test2.Form
and use it only once. Why bother with the variable (the control itself serves
as variable) and think this syntax is wrong. Give an example of the selected
value from this control. Then you want to go to other form and set focus to
the control [License Tag Number]? Is the other form already open?

Suggest not using spaces or symbols or punctuation in ANY names (tables,
queries, forms, fields, controls). I always prefix control names as
indication of the type (tbxLicenseTagNumber, cbxLicenseTagNumber,
lbxLicenseTagNumber). Also clarifies that I am referring to a control and not
a record field.
Form2 is has a list box to display the desired license plate found, the forms
are bound by license tag number. text box has the after event. character
field 10.

I have a record source for form2 called visitorlog, the table.

Private Sub txtSearchReg_AfterUpdate()
Dim rs As DAO.Recordset
Dim frmAny As Form

If Len(Me.txtSearchReg & "") <> 0 Then 'Optional line
Set frmAny = Me.TEST2.Form
Set rs = frmAny.RecordsetClone
rs.FindFirst "[License Tag Number] = " & Chr(34) & Me.txtSearchReg & Chr(34)

If rs.NoMatch = False Then Me.Bookmark = rs.Bookmark

this is the line that fails
frmAny.[License Tag Number].SetFocus

DoCmd.FindRecord Me!List27, acEntire
Me.txtSearchReg = Null
End Sub
error is;
object doesn support this property or method.
Thanks
Ray
 
J

June7 via AccessMonster.com

Depending how ‘name of subform control’ is used could mean the control that
holds the form being used as a subform or some control on the subform. So
this is a form/subform structure (names form1 and form2)? So in this case is
meant to refer to the control that holds the subform, example name:
ctrLicenseTags (ctr for 'container').

Private Sub txtSearchReg_AfterUpdate()

Dim rs As DAO.Recordset
'not including the frmAny variable because never done that before, I just
refer directly to the form

Set rs = Me.ctrLicenseTags.Form.RecordsetClone

rs.FindFirst "[License_Tag_Number] = '" & Me.txtSearchReg & "'" 'use the
apostrophe delimiters if is a string value

If rs.NoMatch = False Then Me.ctrLicenseTags.Form.Bookmark = rs.Bookmark

Me.ctrLicenseTags.License_Tag_Number.SetFocus 'not sure about this syntax,
I haven't tried setting focus to a subform control

Me.txtSearchReg = Null

End Sub

the txtSearchreg and list27 box are both unbound...source for both forms is
visitorlog table, order by license tag number, linked by license tag number
Ray J
So all of this code is behind Form2? You set variable frmAny = Me.Test2.Form
and use it only once. Why bother with the variable (the control itself serves
[quoted text clipped - 35 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top