Page 2 of 2 FirstFirst 12
Results 16 to 29 of 29
  1. #16
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    Ok I have attached the dbase.


    Thanks.

  2. #17
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    my winzip fre trial expired and my company policy is not allowing me to download another zip software . . .

    Any chance you can strip a copy of your db down to the bare essentials so you can post the stripped-down version here without having to zip it?

    Sorry!

  3. #18
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    Ok, try this one.

  4. #19
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    which form do you enter the new ID on??

  5. #20
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    New "INPUT_Data (NewFacility)"
    Existing "INPUT_Data (ExistingFacility)"

  6. #21
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Ok. Let's start again.

    I just read through this whole thread to see where I got off track.

    I was under the impression that:
    1. You want a popup window to appear when you click the button on the Switchboard.
    2. You already have the Popup window [Form] designed and that it opens when you click that button.

    I'm looking all over for where you've put the code sample I gave you but I can't find it.

    You're using Code Macros to do your work.
    I was talking about using the 'Code Builder' to write code to do your work for you.

    I'm not very familliar with using embedded macros - because I found it limiting when I knew what I needed to do but couldn't find a macro action - or combination of macro actions to achieve it.

    I'm not sure how to advise you if you want to go down the embedded macro road - simply because I have not used embedded macros.

    Where are you typing in the MemID that you want to search for in your Table?

    I thought you were typing in a MemberID [MedicaidID] into a TextBox on a Form and then - if that ID is already in your Table - opening up one form - and if it is not - opening up a different form.

    Isn't that your goal?

    If so - which Form is it that you type in that number to determine if it is already in your system or not?


  7. #22
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    I was entering the code in the properties area for Form1 in the OnOpen action by clicking the build button. I do not have to use a macro.

    I may have deleted prior to sending you to copy, since it did not work for me.

  8. #23
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    There's no Form1 in the db you sent me.

  9. #24
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    Sorry Form1 was the generic name I was using instead of the actual name.
    Form2 = "INPUT_Data (NewFacility)"
    Form1 = "INPUT_Data (ExistingFacility)"

  10. #25
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    So . . . back to my other question:

    Doesn't there have to be another form - into which you type your ID - so that your program can determine whether to open Form1 or Form2?

  11. #26
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    So are you saying I need to create another form linked to my main table ("Master_Facility_List_Table") to be a search form and have the code determine whether to open Form1 = "INPUT_Data (ExistingFacility)" or Form2 = "INPUT_Data (NewFacility)"?

    If the answer is yes, would the form need to only containt the Medicaid_ID as the search field or would I also need the Name field since it is mentioned in the code?

  12. #27
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Yes - create another Form.
    It doesn't have to be linked to any Table.

    Create a Form in Design View [Create -> Form Design].
    Add a Text Box [name it MedicaidID].
    Add a Command Button [if the command button wizard opens - click Cancel].

    Then:
    Select the Button.
    Open the Property Sheet and then Event tab.
    Click the Ellipsis [...] to the right of On Click.
    Choose 'Code Builder' [the VBA Editor will open].
    Between the two lines in the VBA Editor:
    Code:
     
    Private Sub Command0_Click()
    'Code will be in here . . . 
     
    End Sub
    is where you will put the code example I was discussing with you earlier in the thread. When you run the Form and click the button - the code in there will execute.

    When you've got it working, clicking the button on this form will take the ID you enter into the text box on the Form, find out if it already exists in your Table and then accordingly open Form1 or Form2.

    I hope this helps!

  13. #28
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    Ok, I created the form with the textbox and button. Adding the following code to the on click:

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

    I am now getting a
    runtime error '2185':
    You can't reference a property or method for a control unless the
    control has the focus.

  14. #29
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    You need to 'SetFocus' to the text box before you can reference what is in it.
    Also - you had a syntax error.
    My changes are in red.

    Code:
    Private Sub Command3_Click()
    Dim MedID As String
    ' Get Value from Medicaid_ID textbox on the Form:
    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
    Try that and see if it works.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Open 2nd Form with 2 criteria?
    By Robeen in forum Forms
    Replies: 1
    Last Post: 09-19-2011, 10:20 AM
  2. Replies: 1
    Last Post: 06-12-2011, 07:08 AM
  3. Replies: 1
    Last Post: 07-02-2010, 03:55 AM
  4. Different Criteria from forms
    By WJReid in forum Access
    Replies: 2
    Last Post: 06-14-2010, 05:49 AM
  5. Open form based on Subform criteria
    By Suzan in forum Programming
    Replies: 0
    Last Post: 04-25-2006, 02:28 PM

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