llap
12-29-2000, 06:26 AM
I have the following form:
"Main" which has:
1. Subform: frm1 which has:
1. Combobox: Combo1-source:tblParts
2. Detail: PartNumber-source:tblParts
record found using Combo1 or scroll
bar -- this works fine.
2. CmdButton: cmd2
On click it opens form: "frm2"
Based on query using frm1 PartNumber
-- this works fine.
3. Form: frm2-reference listing components for frm1 field PartNumber. When I doubleclick on an item in the list, the
item is copied into txtBox1 on Main, then frm2 is closed.
-- this works fine..
4. Textbox: txtBox1-holds component# from frm2 temporarily to load into Combo1 and locate in frm1 to do a 2nd search on this part # to see if it also has
components of its own.
Combo1 is a lookup for PartNumber that originally works fine from frm1. The code is as follows (after Update)
Me.Requery
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PartNumber] = '" & Me![Combo1] & "'"
Me.Bookmark = rs.Bookmark
Me.[PartNumber].SetFocus
I'm trying to use the same code when I return to frm1 from frm2 using the
on activate method for frm1, but I am not able to use the clone method at this point.
The code:
Private Sub Form_Activate()
Me.txtBox1.Requery
If Not Len(Me.txtBox1) = 0 Then
Me.Requery
[Forms]![main]![frm1]![Combo1] = Me.txt1 'this works OK
[Forms]![main].Form![frm1].SetFocus 'this works OK
…
the original findfirst code (above) when inserted at this point - causes an runtime error '91': "Object variable or with block not set"
I'm trying to use the original code to find the newly selected PartNumber from frm2
If I doubleclick on PartNumber item in frm2, it is correctly placed in txtBox1,
Combo1 is correctly updated, and focus is on frm1. I don't want to have to reclick in Combo1 to start the process over again - but if I do - it works OK. I want to trigger the 2nd lookup by doubleclicking in frm2. The info is there. I think I'm not sure how to
address the original recordset so as to refire the findfirst method the seconde time.? Any thoughts or help would be appreciated! Thanks!
....I've solved my own problem....
The seconde instance of "Me" no longer refers to the subform frm1, rather it is now refering to the main form "Main". After I made that correction, all I had to do was use the FindFirst method as follows:
[forms]![main]![frm1].form.recordset.FindFirst "[PartNumber] = '" & [forms]![main]![frm1]![Combo1] & "'"
This is so simple, yet if you are just learning to use Access or objet programming, it may not be obvious to you as it was not to me and this may be of some help to you.
[This message has been edited by llap (edited 12-29-2000).]
"Main" which has:
1. Subform: frm1 which has:
1. Combobox: Combo1-source:tblParts
2. Detail: PartNumber-source:tblParts
record found using Combo1 or scroll
bar -- this works fine.
2. CmdButton: cmd2
On click it opens form: "frm2"
Based on query using frm1 PartNumber
-- this works fine.
3. Form: frm2-reference listing components for frm1 field PartNumber. When I doubleclick on an item in the list, the
item is copied into txtBox1 on Main, then frm2 is closed.
-- this works fine..
4. Textbox: txtBox1-holds component# from frm2 temporarily to load into Combo1 and locate in frm1 to do a 2nd search on this part # to see if it also has
components of its own.
Combo1 is a lookup for PartNumber that originally works fine from frm1. The code is as follows (after Update)
Me.Requery
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PartNumber] = '" & Me![Combo1] & "'"
Me.Bookmark = rs.Bookmark
Me.[PartNumber].SetFocus
I'm trying to use the same code when I return to frm1 from frm2 using the
on activate method for frm1, but I am not able to use the clone method at this point.
The code:
Private Sub Form_Activate()
Me.txtBox1.Requery
If Not Len(Me.txtBox1) = 0 Then
Me.Requery
[Forms]![main]![frm1]![Combo1] = Me.txt1 'this works OK
[Forms]![main].Form![frm1].SetFocus 'this works OK
…
the original findfirst code (above) when inserted at this point - causes an runtime error '91': "Object variable or with block not set"
I'm trying to use the original code to find the newly selected PartNumber from frm2
If I doubleclick on PartNumber item in frm2, it is correctly placed in txtBox1,
Combo1 is correctly updated, and focus is on frm1. I don't want to have to reclick in Combo1 to start the process over again - but if I do - it works OK. I want to trigger the 2nd lookup by doubleclicking in frm2. The info is there. I think I'm not sure how to
address the original recordset so as to refire the findfirst method the seconde time.? Any thoughts or help would be appreciated! Thanks!
....I've solved my own problem....
The seconde instance of "Me" no longer refers to the subform frm1, rather it is now refering to the main form "Main". After I made that correction, all I had to do was use the FindFirst method as follows:
[forms]![main]![frm1].form.recordset.FindFirst "[PartNumber] = '" & [forms]![main]![frm1]![Combo1] & "'"
This is so simple, yet if you are just learning to use Access or objet programming, it may not be obvious to you as it was not to me and this may be of some help to you.
[This message has been edited by llap (edited 12-29-2000).]