Results 1 to 12 of 12
  1. #1
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338

    saving a form

    Hello



    I have a main form which my user enter data. One of the fields is a combo box which is set to limit to list. I also set up a form for the combo box, so user can add new data. I would like for my user to be able to open combo box form from the main form and add new data, than close it and when the user goes to the combo box on the main form the data would be there.


    Thank you

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Here is code attached to a command button to open another form. In this case the form is named frmVendor. change the name to reflect your form name and also to reflect the name of your command button. Mine is obviously Command21.

    Code:
    Private Sub Command21_Click()
    On Error GoTo Err_Command21_Click
        Dim stDocName As String
        Dim stLinkCriteria As String
        stDocName = "frmVendor"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_Command21_Click:
        Exit Sub
    Err_Command21_Click:
        MsgBox Err.Description
        Resume Exit_Command21_Click
     
    End Sub
    Alternatively, you could use code to reflect not in list event.

    Look here for a link to that

    http://allenbrowne.com/ser-27.html

    Alan
    Last edited by alansidman; 10-19-2011 at 08:59 PM. Reason: add Not in List link

  3. #3
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    Thank you very much it worked.

  4. #4
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    One more question.
    When i try it on a different computer it doesn't work. Why is this??? Both computers have version 2003.

    Thank you

  5. #5
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    What do you mean it doesn't work? What happens. Which code are you using Mine or Allen Browne's? Same program? Need more information.

  6. #6
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    I'm using your code. When i did it on my home computer it works fine and in my job computer too. Now when i go to someone else computer in my job it doesn't work.

  7. #7
    Stingaway is offline Efficiency Junkie
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Location
    The deep south. Keep going until you hit water basically.
    Posts
    224
    When you say it doesn't work, what is actually happening? Are you getting an error, does the machine explode, etc, etc?

  8. #8
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    Sorry the combo box does open and I'm able to enter the new data. Than I closed the form and go back to the main form then when I go back to the main form and I click on the combo box the new data is not one of the choices. Thanks!

  9. #9
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    When you go back to the original form, has it been closed or was it sitting open in the background? If it was sitting open in the background, then it needs to have a refresh or requery statement.

    On your maintenance form for updating the combo box, do you close the form with a command button or using the x in the upper right hand corner?


    Alan

  10. #10
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    When i go back to the original form it's been sitting open in the background. On the maintenance form i close the form with a command button.

  11. #11
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    This is the vba that i'm using for the command button:
    Private Sub Command7_Click()
    On Error GoTo Err_Command7_Click
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    Exit_Command7_Click:
    Exit Sub

    Can i add Forms("myFormName").Requery to requery the form or should i add it to the command button that closes the form .

    Thank you

  12. #12
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Try it on the close. I am not sure. I would have to test but you can do it.

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

Similar Threads

  1. Replies: 1
    Last Post: 04-19-2011, 01:55 PM
  2. Prevent Saving of Form
    By bburton in forum Access
    Replies: 4
    Last Post: 02-25-2011, 09:26 PM
  3. Calculations in Form not saving to table
    By ld8732 in forum Forms
    Replies: 1
    Last Post: 01-24-2011, 07:31 PM
  4. stopping a form from saving records
    By LAazsx in forum Forms
    Replies: 4
    Last Post: 12-09-2010, 05:48 PM
  5. Closing and saving a form
    By Lxmanager in forum Forms
    Replies: 14
    Last Post: 11-21-2010, 02:04 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