Setfocus problem (1 Viewer)

gguy

Registered User.
Local time
Today, 15:14
Joined
Jun 27, 2002
Messages
104
I have a problem with program that tracks inspections.

I want to open a form in edit mode and have it automatically go to a specific inspection number (insp_num, which is a unique text field in the table). I want the form to populate with the data from the record that coresponds to the insp_num. The insp_num that I want to go to is not the first record in the table. Instead it is about the 2000th record.

I have been trying to use the "setfocus" function in the "on current" event of the form but I'm not getting it done.

My code in the "on current" looks something like this;

[insp_num] = "12345GG"
me.insp_num.setfocus

This only changes the insp_num field on the form to "12345GG", the rest of the form is not populated with the data from the record.

Thanks for your help
 

gguy

Registered User.
Local time
Today, 15:14
Joined
Jun 27, 2002
Messages
104
I added a combo box called [search#] as the first field in the form. I made search# see all the values in the column [insp_num]. I have tried the following code in the afterupdate event. The code bombs on the findfirst function.

Me.RecordsetClone.Findfirst "[Insp_num] = " & Me![search#]
Me.Bookmark = Me.RecordSetClone.Bookmark

The "me![search#]" is showing the correct ID number. [insp_num] is what the field is named in the table, not the form.
 

dcx693

Registered User.
Local time
Today, 10:14
Joined
Apr 30, 2003
Messages
3,265
You didn't need to create a combo box on your form if you didn't want to. I meant to point you to the bookmark technique of moving the form to the desired record by searching for a value in a field.

Anyway, is [Insp_num] a field in your form? What I mean is, is [Insp_num] feeding any control in your form? It doesn't have to be the case that the field and the control are named the same. But somewhere [Insp_num] must be a field in the recordsource of the form. Also, I would advise against using "special" characters in field names. A name like [search#] might cause confusion down the road.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 10:14
Joined
Feb 19, 2002
Messages
43,485
If the Insp_num field is text, you need to surround it with quotes:

Me.RecordsetClone.Findfirst "[Insp_num] = '" & Me![search#] & "'"
Me.Bookmark = Me.RecordSetClone.Bookmark
 

Users who are viewing this thread

Top Bottom