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 a
subroutine as below but Access generates the following
error message:
"App1 can't find the form 'f_Form' refered to in a macro
expression or in VBA code".
I am not referencing the form right but I have tried many
ways. I don't know if its even possible to do it this
way. Can someone please help.
Robert.
******************************************************
Public Sub SetFormTo(f_Form As Form, _
ctl_LstB_MainFormListBox1 As Control, _
s_NameOfColumnIDInTable As String)
Dim rs As Object
Set rs = f_Form.Recordset.Clone
rs.FindFirst "'[s_NameOfColumnIDInTable]' = " & _
Str(Nz(Forms!f_Form![ctl_LstB_MainFormListBox1], 0))
If Not rs.EOF Then f_Form.Bookmark = rs.Bookmark
Set rs = Nothing
End Sub
******************************************************
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 a
subroutine as below but Access generates the following
error message:
"App1 can't find the form 'f_Form' refered to in a macro
expression or in VBA code".
I am not referencing the form right but I have tried many
ways. I don't know if its even possible to do it this
way. Can someone please help.
Robert.
******************************************************
Public Sub SetFormTo(f_Form As Form, _
ctl_LstB_MainFormListBox1 As Control, _
s_NameOfColumnIDInTable As String)
Dim rs As Object
Set rs = f_Form.Recordset.Clone
rs.FindFirst "'[s_NameOfColumnIDInTable]' = " & _
Str(Nz(Forms!f_Form![ctl_LstB_MainFormListBox1], 0))
If Not rs.EOF Then f_Form.Bookmark = rs.Bookmark
Set rs = Nothing
End Sub
******************************************************