Searching for a record with VBA

pjStyle

Registered User.
Local time
Today, 10:49
Joined
Nov 24, 2003
Messages
13
I have a question. I want to able to search for a record in a form using VBA.
I've constructed the following while loop:

Sub SelectCurrentBeg(dBegid As Double)
Dim temp As Double
temp = Begid.Value

While temp <> dBegid
DoCmd.GoToRecord , , acNext
temp = Begid.Value
Wend
End Sub

Now the Begid.Value is a editbox on the form bound to a field in a table. The thing is, the value which the compiler returns from the editbox is always the same. Where on the form i see the value change everytime i go to a next record.
I've also tried repainting the form on every new record, but for some reason i always end up with the same value :confused:

What am I doing wrong??

Regards,

Ted de Vries
 
Hi,

Do you know about DAO?

If you make a reference to MS DAO, then,

if you copy the following into the form code;

Sub SelectCurrentBeg_DAO(dBegid As Double)

Dim rst As Recordset
Set rst = Me.RecordsetClone

rst.FindFirst "Begid = " & dBegid
Me.Bookmark = rst.Bookmark

End sub

This will find dBegid(if this is the ID field name in the forms table). Just call the sub procedure as normal..
 
Sorry for the late reply, but I really want to thank you for your reply! It was really helpful :D
 

Users who are viewing this thread

Back
Top Bottom