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

Combo Box Control

P: 25
I'm sorry if this question sounds stupid to you.

I'm trying to create a combo box which can allow the user to choose the desired table to insert some records into. This is wat i have.. it doesn't work as it's something i just made up and tot i give it a try.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo0_AfterUpdate(Cancel As Integer)
  2. Dim Seltable As String
  3.  
  4.     Seltable = Me.Combo0.Column(1)
  5.  
  6. If Seltable = "CustData" Then
  7.     DoCmd.RunSQL "INSERT INTO [CustData] SELECT * FROM Template"
  8. End If
  9. End Sub
Please and Thank you!!
Sep 13 '07 #1
Share this Question
Share on Google+
3 Replies


JConsulting
Expert 100+
P: 603
I'm sorry if this question sounds stupid to you.

I'm trying to create a combo box which can allow the user to choose the desired table to insert some records into. This is wat i have.. it doesn't work as it's something i just made up and tot i give it a try.

Private Sub Combo0_AfterUpdate(Cancel As Integer)
Dim Seltable As String

Seltable = Me.Combo0.Column(1)

If Seltable = "CustData" Then
DoCmd.RunSQL "INSERT INTO [CustData] SELECT * FROM Template"
End If
End Sub


Please and Thank you!!
Try
Expand|Select|Wrap|Line Numbers
  1. CurrentDB.Execute "SELECT * INTO [CustData] FROM Template"
  2.  
J
Sep 13 '07 #2

P: 25
Try
Expand|Select|Wrap|Line Numbers
  1. CurrentDB.Execute "SELECT * INTO [CustData] FROM Template"
  2.  
J

This will only work for one table right? how can u make [CustData] a varable so if the user were to choose a different table it will still work.
Sep 13 '07 #3

JConsulting
Expert 100+
P: 603
This will only work for one table right? how can u make [CustData] a varable so if the user were to choose a different table it will still work.
Expand|Select|Wrap|Line Numbers
  1. CurrentDB.Execute "SELECT * INTO " & me.combo0.column(1) & " FROM Template"
  2.  
  3.  and you might need ticks around the variable because it's a string
  4.  
  5. CurrentDB.Execute "SELECT * INTO '" & me.combo0.column(1) & "' FROM Template"
  6.  
Sep 13 '07 #4

Post your reply

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