Results 1 to 11 of 11
  1. #1
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67

    Simple Nav Form Code Not Working

    Hi,



    I have a form with an unbound text box called SSN. I want user to enter a Social Security Number there and click a button which runs the following:

    DoCmd.OpenForm "frmDropStudents", , , "[SocialSecurity] = " & [SSN]

    frmDropStudents is opening as "filtered" showing a blank record.

    This doesn't work either (same result as above):
    DoCmd.OpenForm "frmDropStudents", , , "[SocialSecurity] = " & Me.SSN

    Can anybody help?

    ps ACCESS 2007

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The [SSN] field *should* be a text field. Try:
    DoCmd.OpenForm "frmDropStudents", , , "[SocialSecurity] = '" & Me.SSN & "'"

  3. #3
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67
    That works. I will analyze it and compare it to mine in an attempt to learn something =).

    THANKS!!!!

  4. #4
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67
    BTW, is there a simple way to close the orig form with the SSN field?

    Private Sub cmdFind_Click()
    DoCmd.OpenForm "frmDropStudents", , , "[SocialSecurity] = '" & Me.SSN & "'"
    DoCmd.Close
    End Sub

    Just adding DoCmd.Close doesn't work.
    Last edited by alsoto; 04-07-2009 at 09:46 AM. Reason: grammar

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    DoCmd.Close acForm, Me.Name, acSaveNo

  6. #6
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67
    Private Sub cmdFind_Click()
    DoCmd.OpenForm "frmDropStudents", , , "[SocialSecurity] = '" & Me.SSN & "'"
    DoCmd.Close acForm, Me.Name, acSaveNo
    End Sub

    Didn't work for me, so I just created a macro to close form one and I am running the macro onload event of form 2.

    This should be easier. These are simple things I am trying to do. Leave it to MS.

    Thanks anyway.
    Last edited by alsoto; 04-09-2009 at 02:52 PM. Reason: misspelling

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you saying the using the code I supplied did not close the current form? What is the name of the form where this code resides? If it did not work then you have problems with your system of which you are unaware. They will bite you later on.

  8. #8
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67
    Works now. I forgot the quotes around the form name.

    DoCmd.Close acForm, "frmFindDrop", acSaveNo

    Using the macro wasn't the most efficient way to solve the problem, but I didn't want to be a pest. I guess that's what the forum is for =).

    Thanks for your time. I really appreciate it.

    Al
    Last edited by alsoto; 04-10-2009 at 06:53 AM. Reason: grammar

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Another reason I suggested: DoCmd.Close acForm, Me.Name, acSaveNo
    If you had put in Me.Name as suggested it would have worked as well.

  10. #10
    alsoto is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    67
    I thought I was supposed to replace Me.Name with the form name. Another lesson learned.

    Again, thank you very much for taking the time.

    I need to spend some more time on this board!

    Have a good Easter (if you celebrate it).

    Thanks,
    Al

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad I could help. Yes there is lots to learn just lurking around the forums.

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

Similar Threads

  1. Help with a simple query
    By JohnnyO in forum Queries
    Replies: 1
    Last Post: 02-11-2009, 09:43 PM
  2. Please help w/ simple languages db
    By TalentNation.net in forum Database Design
    Replies: 0
    Last Post: 01-23-2009, 09:11 AM
  3. Replies: 1
    Last Post: 08-10-2008, 01:09 AM
  4. Extremely simple ACCESS DB
    By austin3i62 in forum Access
    Replies: 1
    Last Post: 02-07-2008, 11:51 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