Field search for text

S

s0h0us

I have a table with a number of fields. I would like to allow the user to
perform a search on a field called Asset in table Asset Main, be prompted to
enter the text and have the result, if a match is found, display that field
and its corresponding other fields within that table (i.e., asset
description, asset name, asset location, etc)
Thanks in advance for your help
 
D

Duane Hookom

Create a datasheet subform bound to [Asset Main]. Name the subform
"sfrmAssetMain". Place this subform on another form and add a text box named
"txtFindAsset". In the After Update event of this text box, add this code:

Me.sfrmAssetMain.Form.RecordSource = "SELECT * FROM [Asset Main] " & _
"WHERE Asset Like ""*" & Me.txtFindAsset & "*"";"
 
S

s0h0us

i get an error indicating that a macro could not be found...
i'm probably doing something wrong: i already have a form (Test3) that
displays all the information about the asset. somewhere in this form i would
like to be able to type a new asset name and have the form display that
record.

Duane Hookom said:
Create a datasheet subform bound to [Asset Main]. Name the subform
"sfrmAssetMain". Place this subform on another form and add a text box named
"txtFindAsset". In the After Update event of this text box, add this code:

Me.sfrmAssetMain.Form.RecordSource = "SELECT * FROM [Asset Main] " & _
"WHERE Asset Like ""*" & Me.txtFindAsset & "*"";"

--
Duane Hookom
Microsoft Access MVP


s0h0us said:
I have a table with a number of fields. I would like to allow the user to
perform a search on a field called Asset in table Asset Main, be prompted to
enter the text and have the result, if a match is found, display that field
and its corresponding other fields within that table (i.e., asset
description, asset name, asset location, etc)
Thanks in advance for your help
 
M

Mark Burns

Duane gave you VBA code, not macro text.
Put that into the VBA Event code as he described it and try it again.

....unless your VBA is disabled because of the macro security mode...?

s0h0us said:
i get an error indicating that a macro could not be found...
i'm probably doing something wrong: i already have a form (Test3) that
displays all the information about the asset. somewhere in this form i would
like to be able to type a new asset name and have the form display that
record.

Duane Hookom said:
Create a datasheet subform bound to [Asset Main]. Name the subform
"sfrmAssetMain". Place this subform on another form and add a text box named
"txtFindAsset". In the After Update event of this text box, add this code:

Me.sfrmAssetMain.Form.RecordSource = "SELECT * FROM [Asset Main] " & _
"WHERE Asset Like ""*" & Me.txtFindAsset & "*"";"

--
Duane Hookom
Microsoft Access MVP


s0h0us said:
I have a table with a number of fields. I would like to allow the user to
perform a search on a field called Asset in table Asset Main, be prompted to
enter the text and have the result, if a match is found, display that field
and its corresponding other fields within that table (i.e., asset
description, asset name, asset location, etc)
Thanks in advance for your help
 

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