L
Lisa
I have created an unbound form that I wanted to create a command button to
insert the data into the table (I am doing it this way because I need to do a
DLookup for a particular field on the form that i need to then populate into
the table and the only way that I can think of to get this to populate is to
use a command button). I am having a problem getting my code to work. Im
not an avid VB user, but I had a form that had similar code and I copied it
and changed it based on my new data table but it doesn't seem to be working.
Hope someone can help.
Private Sub Command418_Click()
Dim strSQL As String
Dim conDatabase As ADODB.Connection
strSQL = "INSERT INTO TBL_Billing Eval " _
& "(QualityDate, EvalPurpose, EvaluatorID, Campus, SiteLead,
FLM, Employee, FunctionGrp, PolNo, ANI, Duration, TransType, ScorePlan,
TransDate, EvalCompl, CorrectAction, Q1, Q1TrendComm, Q1Comment) Values(" _
& "'" & txt_QualityDate & "'" _
& ", '" & cb_EvalPurp & "'" _
& ", '" & txt_EvalID & "'" _
& ", '" & txt_Campus & "'" _
& ", '" & txt_Lead & "'" _
& ", '" & Txt_FLM & "'" _
& ", '" & txt_EmplID & "'" _
& ", '" & cb_functGrp & "'" _
& ", '" & txt_PolNo & "'" _
& ", '" & txt_ANI & "'" _
& ", '" & txt_duration & "'" _
& ", '" & cb_transtype & "'" _
& ", '" & cb_ScorePlan & "'" _
& ", '" & txt_transdate & "'" _
& ", '" & Frm_EvalCompl & "'" _
& ", '" & frm_CorrectAction & "'" _
& ", '" & Frm_Q1 & "'" _
& ", '" & cb_Q1Trending & "'" _
& ", '" & txt_Q1Comment & "'" _
& ")"
MsgBox "You are adding something else."
Set conDatabase = CurrentProject.Connection
' conDatabase.Execute strSQL
conDatabase.Close
Set conDatabase = Nothing
' MsgBox "Evaluation " & tbWR_ & " has been added."
'
' Now reset the controls on the form to default values
' lb_Sections.Requery
' tbTarget_Date = ""
' tbDate_Logged = Date
' tbWR_ = Null
' cbSegment.Value = Null
' tbSuggestion = Null
' tbSubmitter = Null
' cblocation.Value = Null
' cbWR_Type.Value = Null
' cbAnalyst.Value = Null
' cbLetterSent.Value = 0
' cbchartsdirectory.Value = 0
' FileAttachment.Value = "<enter file name>"
End Sub
insert the data into the table (I am doing it this way because I need to do a
DLookup for a particular field on the form that i need to then populate into
the table and the only way that I can think of to get this to populate is to
use a command button). I am having a problem getting my code to work. Im
not an avid VB user, but I had a form that had similar code and I copied it
and changed it based on my new data table but it doesn't seem to be working.
Hope someone can help.
Private Sub Command418_Click()
Dim strSQL As String
Dim conDatabase As ADODB.Connection
strSQL = "INSERT INTO TBL_Billing Eval " _
& "(QualityDate, EvalPurpose, EvaluatorID, Campus, SiteLead,
FLM, Employee, FunctionGrp, PolNo, ANI, Duration, TransType, ScorePlan,
TransDate, EvalCompl, CorrectAction, Q1, Q1TrendComm, Q1Comment) Values(" _
& "'" & txt_QualityDate & "'" _
& ", '" & cb_EvalPurp & "'" _
& ", '" & txt_EvalID & "'" _
& ", '" & txt_Campus & "'" _
& ", '" & txt_Lead & "'" _
& ", '" & Txt_FLM & "'" _
& ", '" & txt_EmplID & "'" _
& ", '" & cb_functGrp & "'" _
& ", '" & txt_PolNo & "'" _
& ", '" & txt_ANI & "'" _
& ", '" & txt_duration & "'" _
& ", '" & cb_transtype & "'" _
& ", '" & cb_ScorePlan & "'" _
& ", '" & txt_transdate & "'" _
& ", '" & Frm_EvalCompl & "'" _
& ", '" & frm_CorrectAction & "'" _
& ", '" & Frm_Q1 & "'" _
& ", '" & cb_Q1Trending & "'" _
& ", '" & txt_Q1Comment & "'" _
& ")"
MsgBox "You are adding something else."
Set conDatabase = CurrentProject.Connection
' conDatabase.Execute strSQL
conDatabase.Close
Set conDatabase = Nothing
' MsgBox "Evaluation " & tbWR_ & " has been added."
'
' Now reset the controls on the form to default values
' lb_Sections.Requery
' tbTarget_Date = ""
' tbDate_Logged = Date
' tbWR_ = Null
' cbSegment.Value = Null
' tbSuggestion = Null
' tbSubmitter = Null
' cblocation.Value = Null
' cbWR_Type.Value = Null
' cbAnalyst.Value = Null
' cbLetterSent.Value = 0
' cbchartsdirectory.Value = 0
' FileAttachment.Value = "<enter file name>"
End Sub