Results 1 to 4 of 4
  1. #1
    jessgreen167 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    2

    How do i use a button to open a new form under a certain field?

    I am creating a database in Access 2013. I am trying to learn how to use a button to open a new form under a certain field. For example, I am creating a database for contracts. I have multiple contract numbers that have numerous line items under the one contract number. I have a form already created to add the contract information. How do I create a form to add a line item under the certain contract number that's been selected? I hope I'm asking this correctly!!

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You can open forms using criteria. Here is an example that uses a string variable, strWhere. You build the criteria in the string variable and then reference the variable in your Docmd statement.

    Dim strWhere As String
    strWhere = "ContractNumberFieldName = " & Me.ContractNumberControlName
    DoCmd.OpenForm "NameOfForm", acNormal, , strWhere

  3. #3
    jessgreen167 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    2
    Thank you ItsMe. Is this code? In order for this to be done should I know how to write code?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    It is code. You would put it in an event handler. Maybe a click event for a button control. You would need to identify the field name and the control name so the code for the WHERE criteria will work. Also you would need to place the correct form name in the code. I edited my previous post so you can see the names that would need to be edited.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-31-2013, 08:53 AM
  2. Replies: 2
    Last Post: 04-01-2013, 04:23 PM
  3. Button to Open HTML contained in Text Field
    By Douglas Post in forum Access
    Replies: 1
    Last Post: 01-22-2012, 12:12 PM
  4. cmd button to open form
    By stephaniehpcswf in forum Access
    Replies: 1
    Last Post: 02-23-2011, 04:46 PM
  5. Use a command button to open a form
    By johnpaul in forum Forms
    Replies: 24
    Last Post: 09-23-2010, 12:29 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