Results 1 to 6 of 6
  1. #1
    Newbie11 is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Dec 2011
    Posts
    41

    Pass from submform

    I have a Customer Records Subform that displays specifc customer records on the Main Customer Form. I have an Edit Order button that I would like to open up the the Customer Records Form to edit an order.



    I want the form to open to whatever record is selected in the datasheet. Currently it is always opened to the last record. Is there any way to open to the selected record?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    So you select record in the subform and then click button to open a form? You can do edits in the subform?

    I use VBA to open form filtered by the WHERE CONDITION of DoCmd.OpenForm. I always name the subform container control different from the object it holds, like ctrOrder.

    DoCmd.OpenForm "Customer Records Form", , , "OrderID=" & Me.ctrOrder!OrderID, , acDialog

    Then might need to requery the subform after the form closes so new record will show.
    Me.ctrOrder.Requery
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Newbie11 is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Dec 2011
    Posts
    41
    Thanks for the solution!!

    I came across another issue. How can I eliminate the creation of another record where the first name and last name already exist? That is I want to prevent users from creating dupliate files and possibly show a message box that the cusotmer already exists.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You can have code search the data base for the names. But this won't take into account misspelling by user. Better to restrict user selection. Have a combobox with a RowSource that is a query with fields for CustomerID and LastName,FirstName (concatenated as one value). As user types lastname,firstname the combobox will match to items in list. If no match offer user option to enter a new record. This can be handled with the NotInList event of the combobox. http://www.everythingaccess.com/tuto...-lookup-tables

    You can also have a search capability built on form. Refer to tutorials at http://datapigtechnologies.com/AccessMain.htm especially Creating a Basic Search Form in the Access Forms: Tips and Techniques section.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Newbie11 is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Dec 2011
    Posts
    41
    I actually wanted to try something a bit simpler like a DLookup to see if the ID already exists.

    I have the following code:

    If DLookup(ID) = 1 Then
    MsgBox "Patient already exists"
    Else ......
    End if

    However I keep geting a complier error: argument not optional on the DLookup line.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Need to specify the table to search. Literal strings must be in quotes. If search is no match the return is null.
    If Not IsNull(DLookup("ID", "yourtablename", "ID=1")) Then

    Refer to Access Help about DLookup.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Shift By Pass
    By pkstormy in forum Code Repository
    Replies: 4
    Last Post: 03-18-2012, 05:51 PM
  2. Pass-Through Query or ADO, is there a way?
    By Amber_1977 in forum Queries
    Replies: 3
    Last Post: 11-10-2010, 08:56 AM
  3. Pass Value to Form
    By JohnBoy in forum Programming
    Replies: 5
    Last Post: 06-06-2010, 11:26 AM
  4. how to pass pk to subform
    By ahmed.gomaa in forum Forms
    Replies: 9
    Last Post: 03-21-2010, 10:03 AM
  5. Pass a value from a form to another
    By cwwaicw311 in forum Forms
    Replies: 3
    Last Post: 03-16-2010, 12:42 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