Results 1 to 8 of 8
  1. #1
    catluvr is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Kansas
    Posts
    87

    Is it possible to have a form open using different openargs?

    Hello Again!



    I have a search form to search on manufacturers' part numbers. Once the manufacturer's part number is found, it's matched to the correct company-assigned item number and there is a button that the user can click on to open the parts form to that item number to see the additional information about the item. I use openargs to pass the item number to the parts form so that the form opens to the correct part, using DoCmd.FindRecord.

    On a separate form, I have a combo box of item numbers. if the item number isn't in the list, then I want the parts form to open and, using the NewData as openargs, fill in the item number for the user. The user then fills in the rest of the item information and closes the form. The combo box would then re-query. I know HOW to do all of that ...

    Except, in the first case, the item number exists and the parts form opens to the item number that equals the OpenArgs.

    In the second case, the item number does NOT exist, so the parts form would open to add that number. Using OpenArgs, the item number = NewData.

    So, is there a way to do both things?


    Susie
    Kansas

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Seeing your code might help to clarify things, but based on my interpretation of your post, one way might be to pass the value if it exists, and if it doesn't, then you don't pass anything. When checking the OpenArgs property, either it contains a value or it does not. If it does, you use it as you already are. If it doesn't, you take the alternate action but it's not clear what that is. Perhaps it is to open the form in data entry mode (open as DataEntry) in order to create new record?

    You could also create a custom property for the opening form and set its value in the calling code, but I don't see any reason to make this more complicated. Even if you need 2 or more values passed to OpenArgs, it would be simpler to pass a comma separated value list IMO.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    So, is there a way to do both things?
    As Micron notes, it would good to see your code.
    It seems to me what you may need is to test for NewRecord

    Code:
    If Me.NewRecord then
       do something
    Else
       do something else
    End If
    Usually when I use the not in list event with a form, I create the record first in the NIL event, obtain the PKey of the new record, and then open the form to the new record using the PKey in the where argument.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    As Micron and Moke have suggested, it would be helpful to see your code (and table designs in my view). I'm interested in the relationship between MfrPartNum and the CompanyAssignedItemNum.
    If you are working from an authoritative MfrPartNum table, then shouldn't there be a related entry for CompanyAssigndItemNum (at least the set/subset that the company uses)?
    Perhaps a sample of the data to highlight the issue would clarify, since we all seem to be a little unsure of the
    detailed requirement.
    Good luck.

  5. #5
    catluvr is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Kansas
    Posts
    87
    Well, I got caught up installing gutter covers yesterday. BORING!

    Today, I wanted to make sure my code was spiffed up before posting and, somehow, solved my own problem!

    To answer some of the above questions, the company has it's own set of item numbers for parts ... like AG 67 or TS 31. Each of those items can have one or two manufacturers and their part numbers. So, AG 67 could have Widgets. Inc and part number G14-78 AND Acme and part number 678-789. Then TS 31 might have only one manufacturer ... Acme and part number 123-234.

    Frankly, I'm beginning to regret the "sure, I can do that" that I said a few weeks ago.


    Susie
    Kansas

  6. #6
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    Hi Orange
    Just wanted to say thanks for adding the links to the bottom of your posts! It is great reading. I love the explainations in Debugging.
    dave

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    As a general answer to the original question:
    Code:
    Private Sub Form_Load()
    
    Select Case Me.OpenArgs
    
    Case "A"
    'Do something
    
    Case "B"
    'do something else
    
    Case Else
    'do standard load action
    
    End Select
    
    End Sub
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Hi Dave,
    Glad you found the info helpful. There's lots of things in the Database Planning and Design.

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

Similar Threads

  1. Replies: 2
    Last Post: 09-18-2017, 11:09 AM
  2. Replies: 14
    Last Post: 05-26-2015, 04:30 AM
  3. Replies: 3
    Last Post: 02-06-2015, 03:22 PM
  4. Replies: 5
    Last Post: 01-27-2013, 06:04 PM
  5. Open a second form using the OpenArgs
    By blueraincoat in forum Forms
    Replies: 6
    Last Post: 06-02-2011, 06:19 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