Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8119755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:53:57+00:00 2026-06-06T04:53:57+00:00

I want: To be able to open a form, select an item from a

  • 0

I want:

To be able to open a form, select an item from a control box, click a button to open a new form and be able to input new records that have the previously selected item added to their fields.

What I have done so far:

I have made two forms, added the controls in both, added a command button.
I have used MS Access wizard to add this code:

Private Sub CommandNext_Click()
  On Error GoTo Err_CommandNext_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FormX"
    DoCmd.OpenForm stDocName, , , "[BatchID] = " & Me![ListBatch], acFormAdd

  Exit_CommandNext_Click:

    Exit Sub

  Err_CommandNext_Click:

    MsgBox Err.Description
    Resume Exit_CommandNext_Click

End Sub

The third line is mine.

As a result:

  • If the second form isn’t already open, pressing the button on the first form will open the second one with empty data (the text field that should show the value of the parameter is empty).
  • If the second form is already open, pressing the button on the first form will change focus to the second one and it will show an old, existing record that matches the parameter I selected
  • I want to open the second form without any old records showing but with the selected parameter appearing in the designated text field.

In both cases in the second form the Filter property gets populated with the parameter I’ve sent using the button, but that isn’t what I am aiming for.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:53:59+00:00Added an answer on June 6, 2026 at 4:53 am

    Are you aware the 4th argument for the open form command is the where condition or filter to apply?

    If you use the last parameter which is called open arguments (OpenArgs) then you can write code in the 2nd forms open event to set the default value for the column in question.

    The open form code would look something like this:

    DoCmd.OpenForm stDocName, , , , acFormAdd, , Me![ListBatch]
    

    You could then put code similar to the following in this 2nd forms open event:

    Dim defaultID as Long
    defaultID = CLng(Nz(Me.OpenArgs, 0))
    If defaultID = 0 Or IsNull(Me.OpenArgs) Then
        Cancel = True
        Exit Sub
    End If
    Me.TextBoxBatchID.DefaultValue = defaultID
    

    Or if you do not need the ID to be set for every new record you could just set the current value of the control to the defaultID variable.

     Me.TextBoxBatchID = defaultID
    

    Please note the code above would not open the form if the open argument turned out to be empty or 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to click a button and open a new form
I want to show a form when i click on edit button on the
I want to be able to open my website and use some kind of
I want to be able to use Python to open a .csv file like
I want to stop outgoing call and open the application. The app is able
I want to be able to take an image that i have already captured
I want to be able to do the following actions with a form submit
While a user is filling out one form, I want them to be able
I'm creating a Drupal form with a datetime-based javascript popup calendar input that allows
I want to be able to open a .txt file up into a richtextbox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.