Hello All,
I have the following VBA Code, however, every field gets entered other than the LicName into Tbl_EngineerLic. Can someone help me please?
Thank you,
Private Sub Cmd_EnterNewCA_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("SELECT ID FROM Tbl_StateLic WHERE [StateID]='" & Me.State.Value & "' AND [LicID]='" & Me.Lic.Value & "'")
Dim StateLic As Integer
Dim ls As Recordset
Set ls = CurrentDb.OpenRecordset("SELECT ID FROM Tbl_LicName WHERE [LicNameID]='" & Me.LicName.Value & "'")
rs.MoveFirst
StateLic = rs("ID")
Dim qryStr As String
qryStr = "INSERT INTO Tbl_EngineerLic (EmpID,StateLic,LicNameID,LicNum,DateEarned,Expires,Comments)"
Dim valStr As String
valStr = "VALUES ('" & Me.EmpID.Value & "'," & StateLic & "," & Me.LicName.Value & ",'" & Me.LicNum.Value & "',#" & Me.DateEarned.Value & "#,#" & Me.ExpDate.Value & "#,'" & Me.Comments.Value & "')"
qryStr = qryStr & "" & valStr
DoCmd.RunSQL qryStr
End Sub
I have the following VBA Code, however, every field gets entered other than the LicName into Tbl_EngineerLic. Can someone help me please?
Thank you,
Private Sub Cmd_EnterNewCA_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("SELECT ID FROM Tbl_StateLic WHERE [StateID]='" & Me.State.Value & "' AND [LicID]='" & Me.Lic.Value & "'")
Dim StateLic As Integer
Dim ls As Recordset
Set ls = CurrentDb.OpenRecordset("SELECT ID FROM Tbl_LicName WHERE [LicNameID]='" & Me.LicName.Value & "'")
rs.MoveFirst
StateLic = rs("ID")
Dim qryStr As String
qryStr = "INSERT INTO Tbl_EngineerLic (EmpID,StateLic,LicNameID,LicNum,DateEarned,Expires,Comments)"
Dim valStr As String
valStr = "VALUES ('" & Me.EmpID.Value & "'," & StateLic & "," & Me.LicName.Value & ",'" & Me.LicNum.Value & "',#" & Me.DateEarned.Value & "#,#" & Me.ExpDate.Value & "#,'" & Me.Comments.Value & "')"
qryStr = qryStr & "" & valStr
DoCmd.RunSQL qryStr
End Sub