R
Redbeard
I have several comboboxes that essentially do the same thing, but on
different fields. You select an item, and jump to the record that
matches the data in that field. So they all have the same code as
shown below, just with different field and object names.
Private Sub combo1_AfterUpdate()
If combo1 <> "" Then
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Field1] = '" & Me![combo1] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End If
End Sub
I'd like to refactor this into something like the following...
Private Sub combo1_AfterUpdate()
Call General_AfterUpdate(combo1, Field1)
End Sub
Private Sub General_AfterUpdate(combo As ???, Field As ???)
If combo <> "" Then
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Field] = '" & Me![combo] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End If
End Sub
I'm more familiar with Java than VBA and I'm not sure of the proper
syntax or what all the keywords are, but it seems to me that what I
have should be close. If someone could tell me where to find a
glossary like QBasic used to have or online documentation like Java
has, it would also be helpful.
Thanks in advance.
different fields. You select an item, and jump to the record that
matches the data in that field. So they all have the same code as
shown below, just with different field and object names.
Private Sub combo1_AfterUpdate()
If combo1 <> "" Then
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Field1] = '" & Me![combo1] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End If
End Sub
I'd like to refactor this into something like the following...
Private Sub combo1_AfterUpdate()
Call General_AfterUpdate(combo1, Field1)
End Sub
Private Sub General_AfterUpdate(combo As ???, Field As ???)
If combo <> "" Then
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Field] = '" & Me![combo] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End If
End Sub
I'm more familiar with Java than VBA and I'm not sure of the proper
syntax or what all the keywords are, but it seems to me that what I
have should be close. If someone could tell me where to find a
glossary like QBasic used to have or online documentation like Java
has, it would also be helpful.
Thanks in advance.