R
Robert
The following code in the form's vba module works fine
when triggered from a listbox After update event. Its
objective is to synchronize the form to the item in a
listbox that a user clicked on.
******************************************************
Dim rs As Object
Set rs = Me.Recordset.Clone
Me.LstB_MainFormListBox1 = _
LstB_MainFormListBox1.Column(0, 1)
rs.FindFirst "[ClientTypesID] = " & _
Str(Nz(Me![LstB_MainFormListBox1], 0))
Set rs = Nothing
******************************************************
However since I have about 30 forms in my application
where I use this code fragment about 3 to 5 times per
form, I find it is alot of redundant coding. So I would
like to make a subroutine where I could hard code it once
and call this routine from my forms.
I created the subroutine to do what the above code does.
However the line:
"If Not rs.EOF Then f_Form.Bookmark = rs.Bookmark"
does not bookmark the form! I believe that the Findfirst
works but now I have to reflect what Findfirst found
(Synchronize) to the form so the form displays the right
data. The form stays put and nothing happens at the form
level. Maybe bookmarking only works on the form's vba
modules and not in a subroutine like I have it.
I had dropped BOOKMARKING a while back
and now I would like to render my code a little more
efficient and find I am running into the same problem!
Can anyone help!
Robert.
******************************************************
Public Sub SetFormTo(f_FormAny1 As Form, _
ctl_LstB_MainFormListBox1 As Control, _
s_NameOfColumnIDInTable As String)
Dim rs As Object
Set rs = f_FormAny1.Recordset.Clone
rs.FindFirst s_NameOfColumnIDInTable = _
Str(Nz(ctl_LstB_MainFormListBox1, 0))
If Not rs.EOF Then f_FormAny1.Bookmark = rs.Bookmark
Set rs = Nothing
******************************************************
when triggered from a listbox After update event. Its
objective is to synchronize the form to the item in a
listbox that a user clicked on.
******************************************************
Dim rs As Object
Set rs = Me.Recordset.Clone
Me.LstB_MainFormListBox1 = _
LstB_MainFormListBox1.Column(0, 1)
rs.FindFirst "[ClientTypesID] = " & _
Str(Nz(Me![LstB_MainFormListBox1], 0))
Set rs = Nothing
******************************************************
However since I have about 30 forms in my application
where I use this code fragment about 3 to 5 times per
form, I find it is alot of redundant coding. So I would
like to make a subroutine where I could hard code it once
and call this routine from my forms.
I created the subroutine to do what the above code does.
However the line:
"If Not rs.EOF Then f_Form.Bookmark = rs.Bookmark"
does not bookmark the form! I believe that the Findfirst
works but now I have to reflect what Findfirst found
(Synchronize) to the form so the form displays the right
data. The form stays put and nothing happens at the form
level. Maybe bookmarking only works on the form's vba
modules and not in a subroutine like I have it.
I had dropped BOOKMARKING a while back
and now I would like to render my code a little more
efficient and find I am running into the same problem!
Can anyone help!
Robert.
******************************************************
Public Sub SetFormTo(f_FormAny1 As Form, _
ctl_LstB_MainFormListBox1 As Control, _
s_NameOfColumnIDInTable As String)
Dim rs As Object
Set rs = f_FormAny1.Recordset.Clone
rs.FindFirst s_NameOfColumnIDInTable = _
Str(Nz(ctl_LstB_MainFormListBox1, 0))
If Not rs.EOF Then f_FormAny1.Bookmark = rs.Bookmark
Set rs = Nothing
******************************************************