Yes, this can bo done. Yes, the SQL string has to remain a string.
Do this:
Create a combo with a list of your target databases. Then do this with your code:
Dim sTarget As String
Dim sSQL As String
If IsNull(Me.cboTarget) or Me.cboTarget = "" Then
MsgBox "Please select a target database", vbCritical
Exit Sub
Else
sTarget = Me.cboTarget
End If
sSQL = "INSERT INTO tblKPI3Results ( EstLabHrsReqd )SELECT [qryKPI3Results].EstLabHrsReqd IN '" & sTarget & "' FROM [qryKPI3Results];"
DoCmd.RunSQL sSQL
Did that help? It is not a good idea to add non-variables to a SQL string at runtime, that is why you post that cbo value to a string, then concatenate the string into your SQL string, then run your SQL string once it is built. Access has a big problem with this:
DoCmd.RunSQL "INSERT INTO tblKPI3Results ( EstLabHrsReqd )SELECT [qryKPI3Results].EstLabHrsReqd IN '" & Me.cboTarget & "' FROM [qryKPI3Results];"
mmcdonal
Look it up at:
http://wrox.books24x7.com