By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,106 Members | 2,335 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,106 IT Pros & Developers. It's quick & easy.

Access VBA Form - Find if Record Exists

P: 98
I'm trying to do something that I'm not exactly sure how to go about. I know about queries and how to do those, but my form isn't set up for that particular purpose. Like a webpage that has a "Check Username Available" type of function for some, that's exactly what I want to do. All my form consists of right now is a text box, txtUsername, and a command button. My table is named Members with a record column named Username. Any help with this is appreciated.
Dec 5 '08 #1
Share this Question
Share on Google+
4 Replies

Expert 2.5K+
P: 3,072
Checkout the DLOOKUP() function. It will allow you to extract e.g. the password for the value entered in the txtUsername field.

Dec 5 '08 #2

P: 98
I'm not exactly trying to extract a password so to speak. Basically, I just need to write an If statement to see if the value entered in txtUsername is in the column Username. It could just be that I need to develop a string search and search the records for that particular string.
Dec 8 '08 #3

Expert 2.5K+
P: 3,532
Something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub SearchUserNames_Click()
  2.  If Not IsNull(Me.txtUserName) Then
  3.   If DCount("UserName", "NameTable", "[UserName] = '" & Me.txtUserName & "'") > 0 Then
  4.     MsgBox "User Name Found!"
  5.   Else
  6.     MsgBox "User Name Not Found!"
  7.   End If
  8.  End If
  9. End Sub
Linq ;0)>
Dec 8 '08 #4

P: 98
Thanks Linq,
This worked perfectly. All I had to do was tweak it slightly. I appreciate all you guys do for us, especially those still learning.

Dec 8 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.