Results 1 to 6 of 6
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776

    Parameter issue with form load

    Hi all,
    I have a parameter value opening up when i click on a button to load the form.

    Code:
    Private Sub CmdPurchase_Click()
    DoCmd.OpenForm "frmTransPurchase"
    DoCmd.GoToRecord , , acNewRec
    Forms!frmTransPurchase!CboFromAccount = Me.AccountID
    Forms!frmTransPurchase!TransAmount.SetFocus
    End Sub
    Click image for larger version. 

Name:	purchse.jpg 
Views:	16 
Size:	111.5 KB 
ID:	47244

    When I click the button to open this form with code above, it does not go to new record, it goes to first record with this parameter and when i click OK or cancel, then
    it goes to new record? Not sure at all why this is happening but very annoying to say the least. I can see it opens to first record but doesnt load the sub form data but gives a parameter


    box instead. Is there some reason why this would happen or a way to make it go away?

    Thanks
    Dave

  2. #2
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi all,
    I added a Forms!frmTransPurchase.Refresh to that code and solved the issue.
    Sorry
    Dave

  3. #3
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Well it doesn't appear to be much to do with the code you posted. Rather it's probably a broken reference in the form. A lot of times it's because of a typo, something is mispelled. IE maybe the combo's actual name is CboCategory and not CboCatagory?

    Poke around the frmTransPurchase and its subform and their code to troubleshoot this.

    Finally, I'm not sure if it matters but maybe try the following syntax:
    Code:
    Forms!Mainform!Subform1.Form!ControlName
    which would look like:
    Code:
    Forms!frmTransPurchase!sfrmCatagoryDetailPurchase.Form!CboCatagory
    http://access.mvps.org/access/forms/frm0031.htm

  4. #4
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi kd,
    I am really not sure as I dont have that code in the app, it is just referencing that subform dropdown CboCatagory for some reason. I went over spelling and everything. There should be no reason it calls it out
    but it wants a value for some reason. I have three forms all similar and they all did the same thing. If i open the form directly from nav pane, it opened up just normal, no parameter and went to first recrod. If I
    opened from the button, then i got the parameter. I put in the code between the open event and the go to event Forms.frmTransPurchase.Requery and it now opens fine. I did the same to the other two forms and
    works like a charm. I dont know why it it wanted to call to that parameter at all but it did and once I added the new code, it goes straight to new record. There should not have been any reason for it to call out this
    parameter as the data is there, nothing is misspelled, but for some reason that specific data was not loading on form. No Idea but it now does work correctly. The weird thing is this parameter is not in the form, subform,
    or query so I couldnt put that code "Forms!frmTransPurchase!sfrmCatagoryDetailPurchase. Form!CboCatagory"
    Not even sure where it would go to be honest...

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,943
    That is not how you spell Category though?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Hmm. Maybe it's related to the issue this article addresses http://www.fmsinc.com/microsoftacces...ink-fields.asp

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

Similar Threads

  1. Query Values dont match destination Issue on form load
    By d9pierce1 in forum Programming
    Replies: 8
    Last Post: 04-18-2021, 11:38 AM
  2. Replies: 5
    Last Post: 11-18-2016, 10:27 AM
  3. Replies: 1
    Last Post: 05-04-2016, 02:34 PM
  4. Closing a parameter form on Report Load
    By uaguy3005 in forum Reports
    Replies: 3
    Last Post: 01-12-2016, 01:23 PM
  5. Form/Combo box parameter issue.
    By Bmo in forum Forms
    Replies: 2
    Last Post: 05-06-2010, 03:41 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