D
dst393
I am getting an error with my insert statement. The code is very long but
here it is.....
strInsert = "Insert into Maintable (CourseTitle, Assignee, Location,
StartDate, EndDate, " & _
"LocationRvedDate, DateInstructorCleared, PostMTB,
PostTCRS, PostSATERN, SWRDte, RoomCapacity, " & _
"CoordProvDte, CloseOutDte, InvoiceRecved, EvalTechSent,
DCNConfirm, Vendor, VendorAddress, " & _
"VidRema, MaxOfStudents, EstimatedCost, EquipmentNeeded,
EntranceG, POC, POCPhone, POCFax," & _
"PostCCLog, EvalRecved, MatRetToNSTC, CopyToSPLC,
FinanSent, TVViewDte, " & _
"Cancelled, Postponed, Starttime, Endtime, Remarks,
Category, Targetaudience, " & _
"Rescheduled, CoursNumber, Coursetype, Instructor,
ScheduleOffID, SiteMap, SelfReg) VALUES ("
If IsNull(txtCT.Value) Then 'Course Title
MsgBox "Please enter the course title"
strInsert = ""
Exit Sub
Else
strCrsNme = txtCT.Value
strInsert = strInsert & "'" & strCrsNme & "', "
End If
If IsNull(cboAss.Value) Then 'Assignee
MsgBox "Please select an assignee"
strInsert = ""
Exit Sub
Else
lAssi = cboAss.ListIndex
strAss = cboAss.Value
strInsert = strInsert & "'" & strAss & "', "
End If
If IsNull(cboLoc.Value) Then 'Location
MsgBox "Please select a location"
strInsert = ""
Exit Sub
Else
lLoca = cboLoc.ListIndex
strLoc = cboLoc.Value
strInsert = strInsert & "'" & strLoc & "', "
End If
If IsNull(txtStartDate.Value) Then 'Start Date
MsgBox "Please enter the start date"
strInsert = ""
Exit Sub
Else
dtStrtDte = txtStartDate.Value
strInsert = strInsert & "#" & dtStrtDte & "#, "
End If
If IsNull(txtEndDate) Then 'End Date
MsgBox "Please enter the end date"
strInsert = ""
Exit Sub
Else
dtEndDte = txtEndDate.Value
strInsert = strInsert & "#" & dtEndDte & "#, "
End If
If IsNull(txtDteLocRes.Value) Then 'Date Location Reserved
txtDteLocRes.Value = ""
strInsert = strInsert & ", "
Else
dtLocResved = txtDteLocRes.Value
strInsert = strInsert & "#" & dtLocResved & "#, "
End If
If IsNull(txtDteInstructClred.Value) Then 'Date Instructor Cleared
dtInstClred = ""
strInsert = strInsert & ", "
Else
dtInstClred = txtDteInstructClred.Value
strInsert = strInsert & "#" & dtInstClred & "#, "
End If
If IsNull(txtMTBPost.Value) Then 'Post in MTB
dtPostMTB = ""
strInsert = strInsert & ", "
Else
dtPostMTB = txtMTBPost.Value
strInsert = strInsert & "#" & dtPostMTB & "#, "
End If
If IsNull(txtPostTCRS.Value) Then 'Post in TCRS
dtPostTCRS = ""
strInsert = strInsert & ", "
Else
dtPostTCRS = txtPostTCRS.Value
strInsert = strInsert & "#" & dtPostTCRS & "#, "
End If
If IsNull(txtPostSAT.Value) Then 'Post in SATERN
dtPostSATERN = ""
strInsert = strInsert & ", "
Else
dtPostSATERN = txtPostSAT.Value
strInsert = strInsert & "#" & dtPostSATERN & "#, "
End If
If IsNull(txtDteSWRVB.Value) Then 'Date SWR Provided
dtSWRProv = ""
strInsert = strInsert & ", "
Else
dtSWRProv = txtDteSWRVB.Value
strInsert = strInsert & "#" & dtSWRProv & "#, "
End If
lblMaxNum = Val(MaxCap_lbl.Caption) 'Maximum Capacity
strInsert = strInsert & lblMaxNum & ", "
If IsNull(txtCooProDte.Value) Then 'Coordinate Provided Date
dtCooProv = ""
strInsert = strInsert & ", "
Else
dtCooProv = txtCooProDte.Value
strInsert = strInsert & "#" & dtCooProv & "#, "
End If
If IsNull(txtClsOut.Value) Then 'Close Out
dtClsOut = ""
strInsert = strInsert & ", "
Else
dtClsOut = txtClsOut.Value
strInsert = strInsert & "#" & dtClsOut & "#, "
End If
If IsNull(txtInvRecved.Value) Then 'Invoice Receive
dtInvRecevd = ""
strInsert = strInsert & ", "
Else
dtInvRecevd = txtInvRecved.Value
strInsert = strInsert & "#" & dtInvRecevd & "#, "
End If
If IsNull(txtEvalTechMon.Value) Then 'Date Evaluation sent to Technical
Monitor
dtEvalTechSent = ""
strInsert = strInsert & ", "
Else
dtEvalTechSent = txtEvalTechMon.Value
strInsert = strInsert & "#" & dtEvalTechSent & "#, "
End If
If IsNull(txtDCNCon.Value) Then 'DCN Confirm
dtDCNConfirm = ""
strInsert = strInsert & ", "
Else
dtDCNConfirm = txtDCNCon.Value
strInsert = strInsert & "#" & dtDCNConfirm & "#, "
End If
If IsNull(txtVendor.Value) Then 'Vendor
strVen = ""
strInsert = strInsert & ", "
Else
strVen = txtVendor.Value
strInsert = strInsert & "'" & strVen & "', "
End If
If IsNull(txtVenAddr.Value) Then 'Vendor Address
strVenAddr = ""
strInsert = strInsert & ", "
Else
strVenAddr = txtVenAddr.Value
strInsert = strInsert & "'" & strVenAddr & "', "
End If
If IsNull(txtVBRem.Value) Then 'Video Broadcast Remarks
strVidBrRem = ""
strInsert = strInsert & ", "
Else
strVidBrRem = txtVBRem.Value
strInsert = strInsert & "'" & strVidBrRem & "', "
End If
lblMaxNum = Val(MaxCap_lbl.Caption) 'Maximum Number of Students
strInsert = strInsert & lblMaxNum & ", "
If IsNull(txtCost.Value) Then 'Cost
strCost = ""
strInsert = strInsert & ", "
Else
strCost = txtCost.Value
strInsert = strInsert & "'" & strCost & "', "
End If
If IsNull(txtEquipNeed.Value) Then 'Equipment Need
strEquipNeed = ""
strInsert = strInsert & ", "
Else
strEquipNeed = txtEquipNeed.Value
strInsert = strInsert & "'" & strEquipNeed & "', "
End If
If IsNull(cboGate.Value) Then 'Gate Entrance
'cboGate.Value = ""
strInsert = strInsert & ", "
Else
lEntGate = cboGate.ListIndex
strGate = cboGate.Value
strInsert = strInsert & "'" & strGate & "', "
End If
If IsNull(txtPOC.Value) Then 'POC
strPOC = ""
strInsert = strInsert & ", "
Else
strPOC = txtPOC.Value
strInsert = strInsert & "'" & strPOC & "', "
End If
If IsNull(txtPOCPhoneNum.Value) Then 'POC Phone Number
strPOCPhoNum = ""
strInsert = strInsert & ", "
Else
strPOCPhoNum = txtPOCPhoneNum.Value
strInsert = strInsert & "'" & strPOCPhoNum & "', "
End If
If IsNull(txtFaxNum.Value) Then 'POC Fax Number
strPOCFax = ""
strInsert = strInsert & ", "
Else
strPOCFax = txtFaxNum.Value
strInsert = strInsert & "'" & strPOCFax & "', "
End If
If IsNull(txtCCPost.Value) Then 'Date Posted in Credit Card
dtPostCC = ""
strInsert = strInsert & ", "
Else
dtPostCC = txtCCPost.Value
strInsert = strInsert & "#" & dtPostCC & "#, "
End If
If IsNull(txtEvalRecved.Value) Then 'Evaluation Received
dtEvalRecevd = ""
strInsert = strInsert & ", "
Else
dtEvalRecevd = txtEvalRecved.Value
strInsert = strInsert & "#" & dtEvalRecevd & "#, "
End If
If IsNull(ckMatRetNSTC) Then 'Material sent to NSTC
ckNSTC = False
strInsert = strInsert & "False, "
Else
ckNSTC = ckMatRetNSTC.Value
strInsert = strInsert & "True, "
End If
If IsNull(ckCopySPLC.Value) Then 'Copy received for the SPLC
ckSPLC = False
strInsert = strInsert & "False, "
Else
ckSPLC = ckCopySPLC.Value
strInsert = strInsert & "True, "
End If
If IsNull(txtFinMail.Value) Then 'Mailed to Finance
dtMailedFinance = ""
strInsert = strInsert & ", "
Else
dtMailedFinance = txtFinMail.Value
strInsert = strInsert & "#" & dtMailedFinance & "#, "
End If
If IsNull(txtDteTVView.Value) Then 'Date TV View
dtTVView = ""
strInsert = strInsert & ", "
Else
dtTVView = txtDteTVView.Value
strInsert = strInsert & "#" & dtTVView & "#, "
End If
If IsNull(txtCan.Value) Then 'Cancel
ckCan = False
strInsert = strInsert & "False, "
Else
ckCan = txtCan.Value
strInsert = strInsert & "True, "
End If
If IsNull(ckPostP.Value) Then 'Postponed
ckPP = False
strInsert = strInsert & "False, "
Else
ckPP = ckPostP.Value
strInsert = strInsert & "True, "
End If
If IsNull(txtStarttime) Then 'Start time
MsgBox "Please enter the start time"
strInsert = ""
Exit Sub
Else
tiStrtTim = txtStarttime.Value
strInsert = strInsert & "#" & tiStrtTim & "#, "
End If
If IsNull(txtEndtime) Then 'End Time
MsgBox "Please enter the end time"
strInsert = ""
Exit Sub
Else
tiEndTim = txtEndtime.Value
strInsert = strInsert & "#" & tiEndTim & "#, "
End If
If IsNull(txtRemarks) Then 'Remarks
strRem = ""
strInsert = strInsert & ", "
Else
strRem = txtRemarks.Value
strInsert = strInsert & "'" & strRem & "', "
End If
If IsNull(cboCat.Value) Then 'Category
MsgBox "Please select a category"
strInsert = ""
Exit Sub
Else
lCat = cboCat.ListIndex
strCat = cboCat.Value
strInsert = strInsert & "'" & strCat & "', "
End If
If IsNull(txtTargetaud) Then 'Target Audience
strTarAud = ""
strInsert = strInsert & ", "
Else
strTarAud = "'" & txtTargetaud.Value & "', "
strInsert = strInsert & strTarAud
End If
If IsNull(ckReS.Value) Then 'Reschedule
ckReSch = False
strInsert = strInsert & "False, "
Else
ckReSch = ckReS.Value
strInsert = strInsert & "True, "
End If
If IsNull(txtCN.Value) Then 'Course Number
MsgBox "Please enter the course number"
strInsert = ""
Exit Sub
Else
strCrsNum = txtCN.Value
strInsert = strInsert & "'" & strCrsNum & "', "
End If
If IsNull(lstCoursetype.Value) Then 'Course Type
MsgBox "Please select a course type"
strInsert = ""
Exit Sub
Else
lCsetype = lstCoursetype.ListIndex
strCrsTyp = lstCoursetype.Value
strInsert = strInsert & "'" & strCrsTyp & "', "
End If
If IsNull(txtInstructor.Value) Then 'Instructor
strInstruct = ""
strInsert = strInsert & ", "
Else
strInstruct = txtInstructor.Value
strInsert = strInsert & "'" & strInstruct & "', "
End If
If IsNull(txtSCOFFID.Value) Then 'Schedule ID
iSchOffID = ""
strInsert = strInsert & ", "
Else
iSchOffID = txtSCOFFID.Value
strInsert = strInsert & iSchOffID & ", "
End If
If IsNull(ckSiteMap.Value) Then 'Site Map
ckSitMap = False
strInsert = strInsert & "False, "
Else
ckSitMap = ckSiteMap.Value
strInsert = strInsert & "True, "
End If
If IsNull(ckbxSR.Value) Then 'Self Registration
ckSelReg = False
strInsert = strInsert & "False)"
Else
ckSelReg = ckbxSR.Value
strInsert = strInsert & "True)"
End If
Am I missing anything? A date is not always present. Should I use null
instead of ''?
here it is.....
strInsert = "Insert into Maintable (CourseTitle, Assignee, Location,
StartDate, EndDate, " & _
"LocationRvedDate, DateInstructorCleared, PostMTB,
PostTCRS, PostSATERN, SWRDte, RoomCapacity, " & _
"CoordProvDte, CloseOutDte, InvoiceRecved, EvalTechSent,
DCNConfirm, Vendor, VendorAddress, " & _
"VidRema, MaxOfStudents, EstimatedCost, EquipmentNeeded,
EntranceG, POC, POCPhone, POCFax," & _
"PostCCLog, EvalRecved, MatRetToNSTC, CopyToSPLC,
FinanSent, TVViewDte, " & _
"Cancelled, Postponed, Starttime, Endtime, Remarks,
Category, Targetaudience, " & _
"Rescheduled, CoursNumber, Coursetype, Instructor,
ScheduleOffID, SiteMap, SelfReg) VALUES ("
If IsNull(txtCT.Value) Then 'Course Title
MsgBox "Please enter the course title"
strInsert = ""
Exit Sub
Else
strCrsNme = txtCT.Value
strInsert = strInsert & "'" & strCrsNme & "', "
End If
If IsNull(cboAss.Value) Then 'Assignee
MsgBox "Please select an assignee"
strInsert = ""
Exit Sub
Else
lAssi = cboAss.ListIndex
strAss = cboAss.Value
strInsert = strInsert & "'" & strAss & "', "
End If
If IsNull(cboLoc.Value) Then 'Location
MsgBox "Please select a location"
strInsert = ""
Exit Sub
Else
lLoca = cboLoc.ListIndex
strLoc = cboLoc.Value
strInsert = strInsert & "'" & strLoc & "', "
End If
If IsNull(txtStartDate.Value) Then 'Start Date
MsgBox "Please enter the start date"
strInsert = ""
Exit Sub
Else
dtStrtDte = txtStartDate.Value
strInsert = strInsert & "#" & dtStrtDte & "#, "
End If
If IsNull(txtEndDate) Then 'End Date
MsgBox "Please enter the end date"
strInsert = ""
Exit Sub
Else
dtEndDte = txtEndDate.Value
strInsert = strInsert & "#" & dtEndDte & "#, "
End If
If IsNull(txtDteLocRes.Value) Then 'Date Location Reserved
txtDteLocRes.Value = ""
strInsert = strInsert & ", "
Else
dtLocResved = txtDteLocRes.Value
strInsert = strInsert & "#" & dtLocResved & "#, "
End If
If IsNull(txtDteInstructClred.Value) Then 'Date Instructor Cleared
dtInstClred = ""
strInsert = strInsert & ", "
Else
dtInstClred = txtDteInstructClred.Value
strInsert = strInsert & "#" & dtInstClred & "#, "
End If
If IsNull(txtMTBPost.Value) Then 'Post in MTB
dtPostMTB = ""
strInsert = strInsert & ", "
Else
dtPostMTB = txtMTBPost.Value
strInsert = strInsert & "#" & dtPostMTB & "#, "
End If
If IsNull(txtPostTCRS.Value) Then 'Post in TCRS
dtPostTCRS = ""
strInsert = strInsert & ", "
Else
dtPostTCRS = txtPostTCRS.Value
strInsert = strInsert & "#" & dtPostTCRS & "#, "
End If
If IsNull(txtPostSAT.Value) Then 'Post in SATERN
dtPostSATERN = ""
strInsert = strInsert & ", "
Else
dtPostSATERN = txtPostSAT.Value
strInsert = strInsert & "#" & dtPostSATERN & "#, "
End If
If IsNull(txtDteSWRVB.Value) Then 'Date SWR Provided
dtSWRProv = ""
strInsert = strInsert & ", "
Else
dtSWRProv = txtDteSWRVB.Value
strInsert = strInsert & "#" & dtSWRProv & "#, "
End If
lblMaxNum = Val(MaxCap_lbl.Caption) 'Maximum Capacity
strInsert = strInsert & lblMaxNum & ", "
If IsNull(txtCooProDte.Value) Then 'Coordinate Provided Date
dtCooProv = ""
strInsert = strInsert & ", "
Else
dtCooProv = txtCooProDte.Value
strInsert = strInsert & "#" & dtCooProv & "#, "
End If
If IsNull(txtClsOut.Value) Then 'Close Out
dtClsOut = ""
strInsert = strInsert & ", "
Else
dtClsOut = txtClsOut.Value
strInsert = strInsert & "#" & dtClsOut & "#, "
End If
If IsNull(txtInvRecved.Value) Then 'Invoice Receive
dtInvRecevd = ""
strInsert = strInsert & ", "
Else
dtInvRecevd = txtInvRecved.Value
strInsert = strInsert & "#" & dtInvRecevd & "#, "
End If
If IsNull(txtEvalTechMon.Value) Then 'Date Evaluation sent to Technical
Monitor
dtEvalTechSent = ""
strInsert = strInsert & ", "
Else
dtEvalTechSent = txtEvalTechMon.Value
strInsert = strInsert & "#" & dtEvalTechSent & "#, "
End If
If IsNull(txtDCNCon.Value) Then 'DCN Confirm
dtDCNConfirm = ""
strInsert = strInsert & ", "
Else
dtDCNConfirm = txtDCNCon.Value
strInsert = strInsert & "#" & dtDCNConfirm & "#, "
End If
If IsNull(txtVendor.Value) Then 'Vendor
strVen = ""
strInsert = strInsert & ", "
Else
strVen = txtVendor.Value
strInsert = strInsert & "'" & strVen & "', "
End If
If IsNull(txtVenAddr.Value) Then 'Vendor Address
strVenAddr = ""
strInsert = strInsert & ", "
Else
strVenAddr = txtVenAddr.Value
strInsert = strInsert & "'" & strVenAddr & "', "
End If
If IsNull(txtVBRem.Value) Then 'Video Broadcast Remarks
strVidBrRem = ""
strInsert = strInsert & ", "
Else
strVidBrRem = txtVBRem.Value
strInsert = strInsert & "'" & strVidBrRem & "', "
End If
lblMaxNum = Val(MaxCap_lbl.Caption) 'Maximum Number of Students
strInsert = strInsert & lblMaxNum & ", "
If IsNull(txtCost.Value) Then 'Cost
strCost = ""
strInsert = strInsert & ", "
Else
strCost = txtCost.Value
strInsert = strInsert & "'" & strCost & "', "
End If
If IsNull(txtEquipNeed.Value) Then 'Equipment Need
strEquipNeed = ""
strInsert = strInsert & ", "
Else
strEquipNeed = txtEquipNeed.Value
strInsert = strInsert & "'" & strEquipNeed & "', "
End If
If IsNull(cboGate.Value) Then 'Gate Entrance
'cboGate.Value = ""
strInsert = strInsert & ", "
Else
lEntGate = cboGate.ListIndex
strGate = cboGate.Value
strInsert = strInsert & "'" & strGate & "', "
End If
If IsNull(txtPOC.Value) Then 'POC
strPOC = ""
strInsert = strInsert & ", "
Else
strPOC = txtPOC.Value
strInsert = strInsert & "'" & strPOC & "', "
End If
If IsNull(txtPOCPhoneNum.Value) Then 'POC Phone Number
strPOCPhoNum = ""
strInsert = strInsert & ", "
Else
strPOCPhoNum = txtPOCPhoneNum.Value
strInsert = strInsert & "'" & strPOCPhoNum & "', "
End If
If IsNull(txtFaxNum.Value) Then 'POC Fax Number
strPOCFax = ""
strInsert = strInsert & ", "
Else
strPOCFax = txtFaxNum.Value
strInsert = strInsert & "'" & strPOCFax & "', "
End If
If IsNull(txtCCPost.Value) Then 'Date Posted in Credit Card
dtPostCC = ""
strInsert = strInsert & ", "
Else
dtPostCC = txtCCPost.Value
strInsert = strInsert & "#" & dtPostCC & "#, "
End If
If IsNull(txtEvalRecved.Value) Then 'Evaluation Received
dtEvalRecevd = ""
strInsert = strInsert & ", "
Else
dtEvalRecevd = txtEvalRecved.Value
strInsert = strInsert & "#" & dtEvalRecevd & "#, "
End If
If IsNull(ckMatRetNSTC) Then 'Material sent to NSTC
ckNSTC = False
strInsert = strInsert & "False, "
Else
ckNSTC = ckMatRetNSTC.Value
strInsert = strInsert & "True, "
End If
If IsNull(ckCopySPLC.Value) Then 'Copy received for the SPLC
ckSPLC = False
strInsert = strInsert & "False, "
Else
ckSPLC = ckCopySPLC.Value
strInsert = strInsert & "True, "
End If
If IsNull(txtFinMail.Value) Then 'Mailed to Finance
dtMailedFinance = ""
strInsert = strInsert & ", "
Else
dtMailedFinance = txtFinMail.Value
strInsert = strInsert & "#" & dtMailedFinance & "#, "
End If
If IsNull(txtDteTVView.Value) Then 'Date TV View
dtTVView = ""
strInsert = strInsert & ", "
Else
dtTVView = txtDteTVView.Value
strInsert = strInsert & "#" & dtTVView & "#, "
End If
If IsNull(txtCan.Value) Then 'Cancel
ckCan = False
strInsert = strInsert & "False, "
Else
ckCan = txtCan.Value
strInsert = strInsert & "True, "
End If
If IsNull(ckPostP.Value) Then 'Postponed
ckPP = False
strInsert = strInsert & "False, "
Else
ckPP = ckPostP.Value
strInsert = strInsert & "True, "
End If
If IsNull(txtStarttime) Then 'Start time
MsgBox "Please enter the start time"
strInsert = ""
Exit Sub
Else
tiStrtTim = txtStarttime.Value
strInsert = strInsert & "#" & tiStrtTim & "#, "
End If
If IsNull(txtEndtime) Then 'End Time
MsgBox "Please enter the end time"
strInsert = ""
Exit Sub
Else
tiEndTim = txtEndtime.Value
strInsert = strInsert & "#" & tiEndTim & "#, "
End If
If IsNull(txtRemarks) Then 'Remarks
strRem = ""
strInsert = strInsert & ", "
Else
strRem = txtRemarks.Value
strInsert = strInsert & "'" & strRem & "', "
End If
If IsNull(cboCat.Value) Then 'Category
MsgBox "Please select a category"
strInsert = ""
Exit Sub
Else
lCat = cboCat.ListIndex
strCat = cboCat.Value
strInsert = strInsert & "'" & strCat & "', "
End If
If IsNull(txtTargetaud) Then 'Target Audience
strTarAud = ""
strInsert = strInsert & ", "
Else
strTarAud = "'" & txtTargetaud.Value & "', "
strInsert = strInsert & strTarAud
End If
If IsNull(ckReS.Value) Then 'Reschedule
ckReSch = False
strInsert = strInsert & "False, "
Else
ckReSch = ckReS.Value
strInsert = strInsert & "True, "
End If
If IsNull(txtCN.Value) Then 'Course Number
MsgBox "Please enter the course number"
strInsert = ""
Exit Sub
Else
strCrsNum = txtCN.Value
strInsert = strInsert & "'" & strCrsNum & "', "
End If
If IsNull(lstCoursetype.Value) Then 'Course Type
MsgBox "Please select a course type"
strInsert = ""
Exit Sub
Else
lCsetype = lstCoursetype.ListIndex
strCrsTyp = lstCoursetype.Value
strInsert = strInsert & "'" & strCrsTyp & "', "
End If
If IsNull(txtInstructor.Value) Then 'Instructor
strInstruct = ""
strInsert = strInsert & ", "
Else
strInstruct = txtInstructor.Value
strInsert = strInsert & "'" & strInstruct & "', "
End If
If IsNull(txtSCOFFID.Value) Then 'Schedule ID
iSchOffID = ""
strInsert = strInsert & ", "
Else
iSchOffID = txtSCOFFID.Value
strInsert = strInsert & iSchOffID & ", "
End If
If IsNull(ckSiteMap.Value) Then 'Site Map
ckSitMap = False
strInsert = strInsert & "False, "
Else
ckSitMap = ckSiteMap.Value
strInsert = strInsert & "True, "
End If
If IsNull(ckbxSR.Value) Then 'Self Registration
ckSelReg = False
strInsert = strInsert & "False)"
Else
ckSelReg = ckbxSR.Value
strInsert = strInsert & "True)"
End If
Am I missing anything? A date is not always present. Should I use null
instead of ''?