Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Access & SQL - using LIKE condidtion

Status
Not open for further replies.

rubertoga

Technical User
Jan 4, 2003
22
US
I have to search for an account that is made up of a letter and then numbers. I want the user to be able to search without the letter. Ihave used the following code:

Private Sub cmdAccountSearch_Click()
On Error GoTo Err_cmdAccountSearch_Click

strAccountNo = Me.AccountNo
If (DCount("AccountNo", "tblAccountBase", "AccountNo LIKE '*" & strAccountNo & "'")) = 0 Then
MsgBox "The Account Number you are searching for is not in the database!"
Me.AccountNo = ""
Me.AccountNo.SetFocus
Else
DoCmd.OpenForm "frmUpdateAccount", acNormal, , "AccountNo = '" & strAccountNo & "'"
DoCmd.Close acForm, "frmAccountSearch", acSaveNo
End If

Exit_cmdAccountSearch_Click:
Exit Sub

Err_cmdAccountSearch_Click:
MsgBox Err.Description
Resume Exit_cmdAccountSearch_Click

End Sub

It opens the form but the record is blank.

Anybody got any ideas.
Thanks
 
its ok i worked it out.

I hadn't used the LIKE condition when opening the form.

Blindness is indeed a disability ;o)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top