Results 1 to 3 of 3
  1. #1
    kaylachris is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2010
    Posts
    21

    Cmd Button/ Text box verification

    I have a Form which I use to access specific records using a text box/ command button combination. The user types in a SSN and then clicks the button and that persons record pulls up in a separate form. Everything works smoothly as long the SSN entered into the text box exist in the table. If the command button is pushed without anything in the text box or a number that cannot be found the SSN field of my Table the first user in the table is pulled up or a blank record.
    I wish to create some type of coding/macro that checks to see if the text box matches any of the SSN in the table before it opens a form. If there is not a match then a dialog box will pop-up simply stating that the SSN could not be found.


    I've been tinkering with DLookup.. but not even sure if that its capable of such a task. I've listed the names of all the items below just in case someone knows some type of coding to help me out (I'm VB stupid lol).

    Text box name: LookUpSSNtext
    Command Button: EditProfileClick
    Table: SoldierData
    Form where text box/cmd button is located: MainPage

    Thanks in advance

  2. #2
    Datagopherdan is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Dec 2008
    Posts
    220
    You can do something like this.

    Code:
    dim intCount as Integer
    intCount=DCount("*","SoldierData","[SSN]=" & Me!LookUpSSNtext)
    if intCount < 1 Then
        MsgBox "No records found that match that SSN", vbInformation
              Exit Sub
    End If

  3. #3
    kaylachris is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2010
    Posts
    21
    I appreciate the input but gonna post my final code... just incase someone else wants to give it a try.. it does everything I want

    Private Sub EditProfileButton_Click()
    If (IsNull(LOOKUPSM)) Then
    Beep
    MsgBox "Please Enter a SSN", vbOKOnly, "SSN not found"
    Exit Sub
    End If
    Dim rst As DAO.Recordset
    Set rst = Me.RecordsetClone
    rst.FindFirst "SoldiersSSN = " & Me.LOOKUPSM
    If Not rst.NoMatch Then
    Me.Bookmark = rst.Bookmark
    DoCmd.OpenForm "SMReview", acNormal, "", "[SoldiersSSN] = Forms![MainPage]![LOOKUPSM]", acFormEdit, acNormal
    Else
    Beep
    If (Eval("MsgBox ('Profile Not Found.@Create New Profile?.@@',20,' Profile Not Found!')")) = vbYes Then
    DoCmd.OpenForm "SMReview", acNormal, "", "", acAdd, acNormal
    End If
    End If
    Set rst = Nothing
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to vertically align text inside a text box ?
    By alexcalgary in forum Forms
    Replies: 2
    Last Post: 10-06-2010, 08:44 AM
  2. Replies: 6
    Last Post: 02-09-2010, 07:53 AM
  3. verification qry!
    By tom4038 in forum Queries
    Replies: 1
    Last Post: 09-24-2009, 02:50 AM
  4. joining text in text boxes
    By jjwilliams73 in forum Forms
    Replies: 1
    Last Post: 08-26-2008, 02:30 PM
  5. Split text field into two text fields
    By Grant in forum Access
    Replies: 6
    Last Post: 01-31-2008, 05:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums