Making a command button to search

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to make a command button on one of my forms that will search for
a particular person in my table using last name
 
Scott said:
I am trying to make a command button on one of my forms that will
search for a particular person in my table using last name

Assuming that your form has a field named [LastName]...

Dim RetVal as String
RetVal = InputBox("Enter Last Name")

If RetVal <> "" Then
Me.Filter = "[LastName] = '" & RetVal & "'"
Me.FilterOn = True
End If
 
Thank you Rick. That worked great

Rick Brandt said:
Scott said:
I am trying to make a command button on one of my forms that will
search for a particular person in my table using last name

Assuming that your form has a field named [LastName]...

Dim RetVal as String
RetVal = InputBox("Enter Last Name")

If RetVal <> "" Then
Me.Filter = "[LastName] = '" & RetVal & "'"
Me.FilterOn = True
End If
 
Got another question for ya.

I am trying to set up a delete button that will delete data from 4 tables
based on the Social Security Number. I have the relationships based from this
number. Any ideas.

Rick Brandt said:
Scott said:
I am trying to make a command button on one of my forms that will
search for a particular person in my table using last name

Assuming that your form has a field named [LastName]...

Dim RetVal as String
RetVal = InputBox("Enter Last Name")

If RetVal <> "" Then
Me.Filter = "[LastName] = '" & RetVal & "'"
Me.FilterOn = True
End If
 
If you didn't get it to work yet then you can use 4 delete sql to run

Docmd.runSql "DELETE Table1Name.* FROM Table1Name WHERE [Social Security
Number] = " & [Social Security Number Parameter]

Docmd.runSql "DELETE Table2Name.* FROM Table2Name WHERE [Social Security
Number] = " & [Social Security Number Parameter]

Docmd.runSql "DELETE Table3Name.* FROM Table3Name WHERE [Social Security
Number] = " & [Social Security Number Parameter]

Docmd.runSql "DELETE Table4Name.* FROM Table4Name WHERE [Social Security
Number] = " & [Social Security Number Parameter]

If the parameter it string type the use that

Docmd.runSql "DELETE Table1Name.* FROM Table1Name WHERE [Social Security
Number] = '" & [Social Security Number Parameter] & "'"

Scott said:
Got another question for ya.

I am trying to set up a delete button that will delete data from 4 tables
based on the Social Security Number. I have the relationships based from this
number. Any ideas.

Rick Brandt said:
Scott said:
I am trying to make a command button on one of my forms that will
search for a particular person in my table using last name

Assuming that your form has a field named [LastName]...

Dim RetVal as String
RetVal = InputBox("Enter Last Name")

If RetVal <> "" Then
Me.Filter = "[LastName] = '" & RetVal & "'"
Me.FilterOn = True
End If
 
Back
Top