Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 35
  1. #16
    sud2017 is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Jul 2017
    Posts
    148
    Hi Preston,



    I am now able to open the form by selecting a value from ComboBox after including the below code. However the form that opens up doesn't show any records. Thanks for any possible help.

    Private Sub Combo8_EventName()
    If Combo8.Value = "Form1" Then
    DoCmd.OpenForm "Form1", , , acFormAdd, , , stLinkCriteria
    End If
    End Sub

  2. #17
    Preston is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2017
    Posts
    55
    Sorry Double Post

  3. #18
    Preston is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2017
    Posts
    55
    What is the Record Source of your form?

    PS, the below code would allow you to do this without having to add conditional code for every form you would open. Just make sure there is a form named after every choice in the combo box. Whenever you add a new form, just add its name to the combo box source list. I would also give Combo8 a mnemonic name as a force of habit. When you have a lot of controls on a form, mnemonics helps you keep them straight without having to go look at design view to figure out which code you should be editing.

    Private Sub Combo8_Change()
    DoCmd.OpenForm Combo8.Value, , , acFormAdd, , , stLinkCriteria
    End Sub

  4. #19
    sud2017 is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Jul 2017
    Posts
    148
    Thanks Indeed for this code. The first image below is what I am getting in the form and the second image is what the form originally contains. The source of records in this form is from a TABLE. Your help would be greatly appreciated.


    Click image for larger version. 

Name:	IMG_20.jpg 
Views:	11 
Size:	199.3 KB 
ID:	29514

    Click image for larger version. 

Name:	IMG_19.jpg 
Views:	11 
Size:	193.3 KB 
ID:	29513

  5. #20
    Preston is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2017
    Posts
    55
    So first image is Form1 opened via your Combo box, second is Form1 opened manually? What is the value of stLinkCriteria? Seems this is where your problem lies. If you haven't stripped out some code in your example, you've given it no value, so it's null.

  6. #21
    sud2017 is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Jul 2017
    Posts
    148
    I am sorry, the record source of the form is Query. Still learning the terminologies.

  7. #22
    Preston is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2017
    Posts
    55
    It's okay, I don't think the source is your problem. I think your link criteria is the problem. If the form/subform is set up to link by Opportunity, I don't hink you even need to specify Link Criteria in the open form command.

  8. #23
    sud2017 is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Jul 2017
    Posts
    148
    This is what I have in main page code.

    Click image for larger version. 

Name:	IMG_22.jpg 
Views:	11 
Size:	179.2 KB 
ID:	29516

  9. #24
    Preston is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2017
    Posts
    55
    Delete everything after acFormAdd (on that line only) and tell me if you see different results.

    PS I'm out for the day. I want to understand more about why you're opening the form this way tomorrow.

  10. #25
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    PMFJI,

    Using
    Code:
    DoCmd.OpenForm Combo8.Value, , , acFormAdd, , , stLinkCriteria

    puts the form in ADD mode. You cannot SEE existing records.

    This is the same thing as opening a form in design view, opening the form properties, clicking on the DATA tab and setting the "Data Entry" property to YES.
    You can ONLY add new records, cannot view existing records.

  11. #26
    sud2017 is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Jul 2017
    Posts
    148
    Hi there, tried it. still the form doesn't show any records Any clue?

  12. #27
    Preston is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2017
    Posts
    55
    Quote Originally Posted by sud2017 View Post
    Hi there, tried it. still the form doesn't show any records Any clue?
    You tried which, ssanfu's suggestion or mine? Because I think ssanfu nailed it.

  13. #28
    sud2017 is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Jul 2017
    Posts
    148
    Thank you so much Preston and ssanfu. I just tried ssanfu's code and it worked fine.

    One thing that I am still struggling with is that the form which opens up doesn't allow me to enter a new record. I want a feature in this form that when an end user opens up this "cost estimation form" he should be able to change quantity of existing line items as well as ADD a record in this form.

    I am beginner to Access so any directions would be highly appreciated. Thanks again both of you.

  14. #29
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

    Preston had most of it. I just explained what the constant "acFormAdd" did.


    The code could/would be
    Code:
    DoCmd.OpenForm Me.Combo8
    however I always take the time to rename object.



    Which is easier to understand when reading code:
    Code:
    DoCmd.OpenForm Me.Combo8

    or

    Code:
    Docmd.OpenForm Me.cboSelectForm


  15. #30
    sud2017 is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Jul 2017
    Posts
    148
    Hi ssanfu,

    Did you mean the code on below image would allow me to add a new entry as well?

    Click image for larger version. 

Name:	IMG_29.jpg 
Views:	7 
Size:	180.5 KB 
ID:	29541

    I am still not able to add any record to line item # 4 as shown in image below.

    Click image for larger version. 

Name:	IMG_34.jpg 
Views:	7 
Size:	241.9 KB 
ID:	29542

    Thanks for any possible help.

    Quote Originally Posted by ssanfu View Post

    Preston had most of it. I just explained what the constant "acFormAdd" did.


    The code could/would be
    Code:
    DoCmd.OpenForm Me.Combo8
    however I always take the time to rename object.



    Which is easier to understand when reading code:
    Code:
    DoCmd.OpenForm Me.Combo8

    or

    Code:
    Docmd.OpenForm Me.cboSelectForm


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

Similar Threads

  1. Replies: 3
    Last Post: 05-09-2017, 08:58 AM
  2. Is Access the right tool for this?
    By tmacg7 in forum Access
    Replies: 3
    Last Post: 03-08-2016, 06:20 PM
  3. Calculate Average Cost in Access
    By cafirf in forum Queries
    Replies: 1
    Last Post: 08-09-2015, 03:32 PM
  4. Access Tool
    By cbende2 in forum Access
    Replies: 10
    Last Post: 06-15-2015, 02:55 PM
  5. Replies: 3
    Last Post: 06-23-2010, 07:33 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