Find a record by selecting a vaue from a combo box

D

David

Hi all
Can anyone help me with the following:-
I have a form called "Log" with a combo box with the following code
Sub CboFind_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[Reference Number] = " & Me![CboFind]
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

which works OK.

However I now need to replace the idea of having the combo control on the
"log" form (which has it's RecordSource linked to a table called "HLR")
with a control button.

The control button will open a form called "Find RefNum" that has a combo
box "CboFind" . And now for a bit of help

When I select the value (which will be record ID's) from the combo box I
need the respective record to be selected on the "Log" form, hence how would
I alter my code?

Any help would be appreciated
 
M

Michel Walsh

Hi,



In the form that you have to look for data, have a PUBLIC sub like:

PUBLIC Sub Finding(RefNumber As long)
' Find the record that matches the RefNumber value.
Me.RecordsetClone.FindFirst "[Reference Number] = " & RefNumber
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub



In your dialog form, make a call to that sub:


If 0 <>len( Me.ControlWithTheRefNumberHere.Value) then
FORMS!formNameHere!Finding Me.ControlWithTheRefNumberHere.Value
End If




Hoping it may help,
Vanderghast, Access MVP
 
D

David

Hi, Michel

Thank you for the information.

All the best Dave

Michel Walsh said:
Hi,



In the form that you have to look for data, have a PUBLIC sub like:

PUBLIC Sub Finding(RefNumber As long)
' Find the record that matches the RefNumber value.
Me.RecordsetClone.FindFirst "[Reference Number] = " & RefNumber
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub



In your dialog form, make a call to that sub:


If 0 <>len( Me.ControlWithTheRefNumberHere.Value) then
FORMS!formNameHere!Finding Me.ControlWithTheRefNumberHere.Value
End If




Hoping it may help,
Vanderghast, Access MVP


David said:
Hi all
Can anyone help me with the following:-
I have a form called "Log" with a combo box with the following code
Sub CboFind_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[Reference Number] = " & Me![CboFind]
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

which works OK.

However I now need to replace the idea of having the combo control on the
"log" form (which has it's RecordSource linked to a table called "HLR")
with a control button.

The control button will open a form called "Find RefNum" that has a
combo box "CboFind" . And now for a bit of help

When I select the value (which will be record ID's) from the combo box I
need the respective record to be selected on the "Log" form, hence how
would I alter my code?

Any help would be appreciated
 

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