Insert Into Table brings up Parameter Value popup

RickRo

Registered User.
Local time
Yesterday, 21:01
Joined
Mar 16, 2013
Messages
18
I'm having difficulty with an Insert Into - I have the following code:
Code:
Private Sub Serial_AfterUpdate()
 Dim MyDB As Database
 Dim hostname As String

  Set MyDB = CurrentDb
  hostname = Me.Serial

   DoCmd.RunSQL "INSERT INTO tblTemp (tmptoHostname) VALUES (" & hostname & ")"

    If Me.Serial = "PDS*" Then
    Me.Serial = Right(Me.Serial, Len(Me.Serial) - 3)

    End If
End Sub

Instead of the value of hostname going into the table, I get a pop up box asking me for parameters. And the popup box's label just happens to be the value of hostname!

Where I am going wrong?

Thanks Much,

Rick
 
Hello Rick,

If the tmptoHostname a String, try enclosing them inside single quotes..
Code:
DoCmd.RunSQL "INSERT INTO tblTemp (tmptoHostname) VALUES ([COLOR=Red][B]'[/B][/COLOR]" & hostname & "[COLOR=Red][B]'[/B][/COLOR])"
If that does not help, try Debugging the code.
 
And that' all it took... thanks pr2-eugin!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom