By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,805 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,805 IT Pros & Developers. It's quick & easy.

How can I save my results?

P: 58
I am creating a DB that contains 2 listboxes in my form and a command button to return results based on both selections in the listboxes. I need a save button to save the reults that are shown in a table. Can anyone tell me if this is possible? If so, how can I create the button so it is enabled after the results are showed?
May 17 '07 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
I am creating a DB that contains 2 listboxes in my form and a command button to return results based on both selections in the listboxes. I need a save button to save the reults that are shown in a table. Can anyone tell me if this is possible? If so, how can I create the button so it is enabled after the results are showed?
Firstly behind the save button you will need code somthing like the following:
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3.    strSQL = "INSERT INTO TableName (Field1, Field2) VALUES ('" & _
  4.       Me!Listbox1 & "', '" & Me!Listbox2 & "')"
  5.    DoCmd.RunSQL strSQL
  6.  
I have assumed in the above code that both listboxes are returning string values. If they are numbers then remove the single quotes.

As for enabling the button. Set the button to
Expand|Select|Wrap|Line Numbers
  1. Me!BtnName.Enabled = False 
in the Form open event.

In the After Update event of both listboxes set the following:
Expand|Select|Wrap|Line Numbers
  1. If IsNull(Me!Listbox1) Or IsNull(Me!Llistbox2) Then
  2.    Me!BtnName.Enabled = False
  3. Else
  4.    Me!BtnName.Enabled = True
  5. End If
May 22 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.