Results 1 to 10 of 10
  1. #1
    DenisM is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2019
    Location
    Sleaford Lincs
    Posts
    29

    I need help using DoCmd.OpenForm

    Hello,

    I hope somebody can give me some help. I have 2 forms, Form 1 (Country Profiles) and Form 2 (Banknotes).
    When I run Form 1, I want the option to display the banknotes for a selected country.


    I have inserted DoCmd.Open form in Form 1 but I cannot get it to execute without Parameter input
    I would like to select a country, then click the View Banknotes button and have Form 2 displayed without keying a parameter.

    Screenshots are attached. Step 1 (Country Profiles Form), Steps 2 & 3 Parameter screenshots, Step 4 (Banknotes Form) and code from Country Profiles Form.

    Thank you.
    DenisClick image for larger version. 

Name:	Step 1 - Form 1.png 
Views:	24 
Size:	137.2 KB 
ID:	45534Click image for larger version. 

Name:	Step 2.png 
Views:	24 
Size:	13.5 KB 
ID:	45535Click image for larger version. 

Name:	Step 3.png 
Views:	24 
Size:	13.8 KB 
ID:	45536Click image for larger version. 

Name:	Step 4 - Form 2.jpg 
Views:	25 
Size:	165.6 KB 
ID:	45532Click image for larger version. 

Name:	Form 1 Code.jpg 
Views:	24 
Size:	60.9 KB 
ID:	45533

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,412
    Try Country_Name='" & Me.Country_Name & "'"

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    When the criteria is text, it must be enclosed in quotes - usually single quotes, otherwise Access might interpret it as a field name. When the field name doesn't exist, you'll get prompted. Try Country_Name = '" & Me.CountryName & "'"

    I coloured, bolded and increased the font to make the single quotes more evident. That would result in "Country_Name = 'Danzig'" or whatever the criteria value is.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Dang! It didn't take me 7 minutes to type that, yet there was no responses when I started.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,412
    Dang! It didn't take me 7 minutes to type that, yet there was no responses when I started.
    More comprehensive answers take longer?

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Yeah, but that took less than 2 minutes. Subtract that from my post time and you get no later than 10:35 and you posted at 10:30 which means when you open a thread, whatever you see is at least 5 minutes old, no? Good thing we're not getting paid based on 1st answer, or even 1st right answer!
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    DenisM is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2019
    Location
    Sleaford Lincs
    Posts
    29
    Click image for larger version. 

Name:	Compile Error.png 
Views:	23 
Size:	53.1 KB 
ID:	45537Thanks for the quick responses but now I get a compile error, I don't think that I have mistyped.

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Your original post shows "Country_name..." not Country_Name..." so your code doesn't compile because there are now unmatched quote pairs.
    I think both answers assumed you'd keep the leading quote but didn't we actually include/specify it. So more like
    "Country_Name = '" & Me.CountryName & "'"
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    DenisM is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2019
    Location
    Sleaford Lincs
    Posts
    29
    Thank you so much for your help. You solved my problem.

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Never mind. Not paying enough attention to my own responses I guess.
    Glad that you have a solution.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-27-2017, 04:10 AM
  2. Replies: 11
    Last Post: 08-22-2017, 05:50 PM
  3. DoCmd.OpenForm with 2 Where Conditions
    By CharissaBelle in forum Programming
    Replies: 3
    Last Post: 10-19-2016, 09:32 AM
  4. What actually happens at docmd.openform
    By Beorn in forum Programming
    Replies: 4
    Last Post: 01-05-2011, 02:19 PM
  5. DoCmd.OpenForm Modification
    By alsoto in forum Forms
    Replies: 6
    Last Post: 05-01-2009, 07:28 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