Results 1 to 10 of 10
  1. #1
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    Form Buttons

    When I hit the Enter key on the keyboard I would like it to automatically process. Currently, I will enter the Medicaid_ID, hit Enter (instead of processing it is tabbing to the button. When I hit Enter again it runs the process.) How do I get the process to run by hitting Enter once after entering the Medicaid_ID in the textbox?

    Here is my current code:
    Private Sub Command3_Click()
    Dim MedID As String
    ' Get Value from Medicaid_ID textbox on the Form:
    Me.Command3.SetFocus
    Me.Medicaid_ID.SetFocus
    MedID = Me.Medicaid_ID.Text
    If IsNull(DLookup("NAME", "Master_Facility_List_Table", "Medicaid_ID = '" & MedID & "'")) Then
    ' NAME is Null because the Medicaid_ID doesn't exist.
    DoCmd.OpenForm "INPUT_Data (NewFacility)"
    Else
    ' NAME is not Null because the Medicaid_ID does exist.
    DoCmd.OpenForm "INPUT_Data (ExistingFacility)"
    End If
    End Sub




    Thanks.

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Try this:

    In Form Design mode - select your Command3 button & open the Property Sheet.
    Under the 'Other' Tab - set Default to Yes.

    Now - when your Form is running - if you hit Enter - it will automatically execute the code behind the Command3 button.

    Remember - even if Enter is hit by accident - this code will execute.


    Hope this helps!
    Last edited by Robeen; 11-30-2011 at 12:22 PM. Reason: typo

  3. #3
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    That worked thanks.

    One more question about my code.

    When I enter the medicaid_ID and click the button and the form opens it does not open to the Medicaid_ID I entered to search.

    How can I filter the form to only open the record of the Mecaid_ID number I entered in the search window?
    Thanks.

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    See if the information on this page From pbaldy helps:
    http://www.baldyweb.com/wherecondition.htm

  5. #5
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    Do I replace the DoCmd.OpenForm "INPUT_Data (ExistingFacility)"
    code with DoCmd.OpenForm "SecondFormName", , , "FieldName = '" & Me.ControlName & "'"?
    What if the textbox on the first form (search form) is a unbound textbox and there is no controlname?

  6. #6
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Yes - you should replace like you said.

    It doesn't matter if the text box on the first form is unbound. As long as it has a value in it - it should work.

    The text box must have a Name.
    Go to the 'All' Tab in the Property Sheet for the text box and you will see 'Name'.

    Have you already looked there for the name of the control?

  7. #7
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    the name of the unbound textbox is also Medicaid_ID.

    Did not work.

  8. #8
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    What is the Data Type of your Medicaid ID field in the "INPUT_Data (ExistingFacility)" form?

    This:
    DoCmd.OpenForm "SecondFormName", , , "FieldName = '" & Me.ControlName & "'"?
    will work if your Medicaid_ID is 'Text' [String] data.

    Is Medicaid_ID a string data type? Or is it Numeric?

  9. #9
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    it is text field

    Here is my current code:
    Private Sub Command3_Click()
    Dim MedID As String
    ' Get Value from Medicaid_ID textbox on the Form:
    Me.Command3.SetFocus
    Me.Medicaid_ID.SetFocus
    MedID = Me.Medicaid_ID.Text
    If IsNull(DLookup("NAME", "Master_Facility_List_Table", "Medicaid_ID = '" & MedID & "'")) Then
    ' NAME is Null because the Medicaid_ID doesn't exist.
    DoCmd.OpenForm "INPUT_Data (NewFacility)", , , "Medicaid_ID = '" & Medicaid_ID & "'"
    Else
    ' NAME is not Null because the Medicaid_ID does exist.
    DoCmd.OpenForm "INPUT_Data (ExistingFacility)"
    End If
    End Sub

  10. #10
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    Lightbulb

    It worked I changed the newfacility line and not the existing.
    Thanks.


    Sorry for the confusion and appreciate the help.

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

Similar Threads

  1. Form Buttons
    By DCV0204 in forum Forms
    Replies: 2
    Last Post: 11-29-2011, 03:21 PM
  2. Command Buttons on form
    By bespra in forum Forms
    Replies: 10
    Last Post: 11-12-2011, 01:50 PM
  3. Replies: 3
    Last Post: 10-29-2011, 04:25 AM
  4. GO TO buttons on form
    By csh in forum Forms
    Replies: 8
    Last Post: 10-23-2011, 06:40 AM
  5. Form and Buttons
    By rmohebian in forum Forms
    Replies: 1
    Last Post: 02-14-2011, 09:57 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