Results 1 to 3 of 3

Thread: Open Form in Add Mode

  1. #1
    Boreal2009 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    2

    Question Open Form in Add Mode

    Hi Everyone,
    I am VERY new to VBA so please bear with me! I am using Access 2003 and I have a form that when it is loaded it prompts the user to answer a yes or no question. When yes is selected I want the form to open in Edit mode and when no is selected I want the form to open in Add mode.

    Below is the code that is attached to the On Load Event. It works perfectly when yes is selected and opens the form in Edit mode. However, when no is selected, the form still opens in Edit mode. I have tried the same code in the On Open Event with the same results. It should also be noted that the form contains a subform.

    I have been searching the web all morning to try and figure this out with no avail. Can anyone provide me with detailed directions on how to solve this problem?

    Thanks in advance!

    Private Sub Form_Load()
    If MsgBox("Is this a Re-Capture?", vbYesNo + vbInformation, "Information Needed") = vbYes Then
    DoCmd.RunMacro "Search Message MACRO"
    DoCmd.RunCommand acCmdFind
    Else
    DoCmd.OpenForm "FORM - Male Capture Information", acNormal, , , acFormAdd, acWindowNormal, OpenArgs
    End If
    End Sub

  2. #2
    terryvanduzee is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    17
    I'm no expert here, but I would think that you need to assign a variable to the message box statement to capture the Yes/no answer.

    Ex:
    response=MsgBox("Is this a Re-Capture?", vbYesNo + vbInformation, "Information Needed")

    Then use the if statement:
    If response=vbYes the...

    As I said, I am no expert.

    Terry

  3. #3
    Boreal2009 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    2

    Open Form in Add Mode

    Hi Terry - Thanks for your responce. I was able to figure out how to make this work for me using the code below:

    Private Sub Form_Load()
    If MsgBox("Is this a Re-Capture?", vbYesNo + vbInformation, "Information Needed") = vbYes Then
    DoCmd.RunMacro "Search Band Message MACRO"
    DoCmd.RunCommand acCmdFind
    Else
    DoCmd.RunCommand acCmdRecordsGoToNew
    End If
    End Sub

    So from one novice to another... Hope this will help you sometime!

    Teresa

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

Similar Threads

  1. Need help w/ Forms/runtime mode
    By TechRetard in forum Access
    Replies: 1
    Last Post: 10-06-2009, 03:40 AM
  2. Opening Form in Data Entry Mode Problem
    By alsoto in forum Forms
    Replies: 1
    Last Post: 05-28-2009, 06:45 PM
  3. Median and Mode for a large table
    By brandon in forum Access
    Replies: 0
    Last Post: 05-08-2008, 08:26 AM
  4. In a field on a Form, on click open another form
    By jackieagra in forum Programming
    Replies: 1
    Last Post: 03-20-2008, 08:44 AM
  5. Form will not open
    By dserbanescu in forum Forms
    Replies: 0
    Last Post: 01-09-2008, 07:48 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
  •  
Tech Forums: Microsoft Office Forums