Want to find a VBA code fragment to search a database field.

  • Thread starter Thread starter OldManEd
  • Start date Start date
O

OldManEd

Where can I find the VBA code that is used to locate a specific record?

I want to search on [Last] by typing in the first, second, third etc letter
of name and each time the code loops(?) thru the record set. I NEED AN
EXAMPLE.

Thanks,
EC
 
You just need to use a Combo box. The property you describe is Auto Expand.
Set that property to Yes.
 
That works but doesn't do what I need.

I have a form that includes ALL the fields. I added a combo box(for
searching). Its default property is Auto Expand. It works. But the combo box
is NOT linked to the rest of the form. In other words, I type letters into
the combo box and when a particular [Last] is located I hit <Enter>. The
record pointer doesn't move; it's still on the first record. How do I get
the record pointer to move to the record that matches the combo box's value?

OMEd






Klatuu said:
You just need to use a Combo box. The property you describe is Auto
Expand.
Set that property to Yes.

OldManEd said:
Where can I find the VBA code that is used to locate a specific record?

I want to search on [Last] by typing in the first, second, third etc
letter
of name and each time the code loops(?) thru the record set. I NEED AN
EXAMPLE.

Thanks,
EC
 
In the After Update event of the Combo:

Dim rst As Recordset

Set rst = Me.RecordsetClone
rst.FindFirst "[SearchFieldName] = '" & Me.MyCombo & "'"
If rst.NoMatch Then
MsgBox "Record Not Found"
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

OldManEd said:
That works but doesn't do what I need.

I have a form that includes ALL the fields. I added a combo box(for
searching). Its default property is Auto Expand. It works. But the combo box
is NOT linked to the rest of the form. In other words, I type letters into
the combo box and when a particular [Last] is located I hit <Enter>. The
record pointer doesn't move; it's still on the first record. How do I get
the record pointer to move to the record that matches the combo box's value?

OMEd






Klatuu said:
You just need to use a Combo box. The property you describe is Auto
Expand.
Set that property to Yes.

OldManEd said:
Where can I find the VBA code that is used to locate a specific record?

I want to search on [Last] by typing in the first, second, third etc
letter
of name and each time the code loops(?) thru the record set. I NEED AN
EXAMPLE.

Thanks,
EC
 
Thanks, this is beginning to work, but not completly. I have to type in the
full name, not just the first few characters. Wonder what I'm doing
wrong????

OMEd



Klatuu said:
In the After Update event of the Combo:

Dim rst As Recordset

Set rst = Me.RecordsetClone
rst.FindFirst "[SearchFieldName] = '" & Me.MyCombo & "'"
If rst.NoMatch Then
MsgBox "Record Not Found"
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

OldManEd said:
That works but doesn't do what I need.

I have a form that includes ALL the fields. I added a combo box(for
searching). Its default property is Auto Expand. It works. But the combo
box
is NOT linked to the rest of the form. In other words, I type letters
into
the combo box and when a particular [Last] is located I hit <Enter>. The
record pointer doesn't move; it's still on the first record. How do I
get
the record pointer to move to the record that matches the combo box's
value?

OMEd






Klatuu said:
You just need to use a Combo box. The property you describe is Auto
Expand.
Set that property to Yes.

:

Where can I find the VBA code that is used to locate a specific
record?

I want to search on [Last] by typing in the first, second, third etc
letter
of name and each time the code loops(?) thru the record set. I NEED AN
EXAMPLE.

Thanks,
EC
 
The combo box is no longer 'Auto Expand.' How does this option get set? I
don't see it in Properties.
OMEd


OldManEd said:
Thanks, this is beginning to work, but not completly. I have to type in
the full name, not just the first few characters. Wonder what I'm doing
wrong????

OMEd



Klatuu said:
In the After Update event of the Combo:

Dim rst As Recordset

Set rst = Me.RecordsetClone
rst.FindFirst "[SearchFieldName] = '" & Me.MyCombo & "'"
If rst.NoMatch Then
MsgBox "Record Not Found"
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

OldManEd said:
That works but doesn't do what I need.

I have a form that includes ALL the fields. I added a combo box(for
searching). Its default property is Auto Expand. It works. But the combo
box
is NOT linked to the rest of the form. In other words, I type letters
into
the combo box and when a particular [Last] is located I hit <Enter>. The
record pointer doesn't move; it's still on the first record. How do I
get
the record pointer to move to the record that matches the combo box's
value?

OMEd






You just need to use a Combo box. The property you describe is Auto
Expand.
Set that property to Yes.

:

Where can I find the VBA code that is used to locate a specific
record?

I want to search on [Last] by typing in the first, second, third etc
letter
of name and each time the code loops(?) thru the record set. I NEED
AN
EXAMPLE.

Thanks,
EC
 
It is the 7th property on the Data tab of the Properties Dialog.

OldManEd said:
The combo box is no longer 'Auto Expand.' How does this option get set? I
don't see it in Properties.
OMEd


OldManEd said:
Thanks, this is beginning to work, but not completly. I have to type in
the full name, not just the first few characters. Wonder what I'm doing
wrong????

OMEd



Klatuu said:
In the After Update event of the Combo:

Dim rst As Recordset

Set rst = Me.RecordsetClone
rst.FindFirst "[SearchFieldName] = '" & Me.MyCombo & "'"
If rst.NoMatch Then
MsgBox "Record Not Found"
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

:

That works but doesn't do what I need.

I have a form that includes ALL the fields. I added a combo box(for
searching). Its default property is Auto Expand. It works. But the combo
box
is NOT linked to the rest of the form. In other words, I type letters
into
the combo box and when a particular [Last] is located I hit <Enter>. The
record pointer doesn't move; it's still on the first record. How do I
get
the record pointer to move to the record that matches the combo box's
value?

OMEd






You just need to use a Combo box. The property you describe is Auto
Expand.
Set that property to Yes.

:

Where can I find the VBA code that is used to locate a specific
record?

I want to search on [Last] by typing in the first, second, third etc
letter
of name and each time the code loops(?) thru the record set. I NEED
AN
EXAMPLE.

Thanks,
EC
 
Thanks for ALL your help. Everything now works!!
OMEd

Klatuu said:
It is the 7th property on the Data tab of the Properties Dialog.

OldManEd said:
The combo box is no longer 'Auto Expand.' How does this option get set? I
don't see it in Properties.
OMEd


OldManEd said:
Thanks, this is beginning to work, but not completly. I have to type
in
the full name, not just the first few characters. Wonder what I'm doing
wrong????

OMEd



In the After Update event of the Combo:

Dim rst As Recordset

Set rst = Me.RecordsetClone
rst.FindFirst "[SearchFieldName] = '" & Me.MyCombo & "'"
If rst.NoMatch Then
MsgBox "Record Not Found"
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

:

That works but doesn't do what I need.

I have a form that includes ALL the fields. I added a combo box(for
searching). Its default property is Auto Expand. It works. But the
combo
box
is NOT linked to the rest of the form. In other words, I type
letters
into
the combo box and when a particular [Last] is located I hit <Enter>.
The
record pointer doesn't move; it's still on the first record. How do
I
get
the record pointer to move to the record that matches the combo box's
value?

OMEd






You just need to use a Combo box. The property you describe is
Auto
Expand.
Set that property to Yes.

:

Where can I find the VBA code that is used to locate a specific
record?

I want to search on [Last] by typing in the first, second, third
etc
letter
of name and each time the code loops(?) thru the record set. I
NEED
AN
EXAMPLE.

Thanks,
EC
 

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

Back
Top