OTWarrior
02-03-2010, 03:09 AM
When I try the following sql in vb, it comes up with an inputbox for the value of [txtContactName] (which is the name of a textbox containing a string on the form where the code is fired from).
for example, if I had typed "Fred" in [txtContactName], then the following would show: (kinda looks like)
inputbox("Fred","Enter Parameter Value")
the sql I am trying to run is:
"INSERT INTO tbl_DOM_ProviderContacts ( nProviderID, nBlockNumber, nDiaryID, lkupProviderBlockType, anBookingID," _
& "curPackageCost, dteDateOfContact, dteTimeOfContact, txtContactName, lkupContactOutcome, curTSA_Cost )" _
& "SELECT qry_DOM_ProviderLookup_ByContract_CofC.nProviderID, qry_DOM_ProviderLookup_ByContract_CofC.nBlockRef, " _
& "tbl_DOM_Diaries.anDiaryID, qry_DOM_ProviderLookup_ByContract_CofC.anContractTypeID, tbl_DOM_Diaries.nDomBookingID, " _
& "qry_DOM_ProviderLookup_ByContract_CofC.nContractedCost, Date() AS Expr1, Time() AS Expr2, " & [txtContactName] _
& " AS Expr3, " & [lkupContactOutcome] & " AS Contactoutcome," & [curTSA_Cost] & " AS TSA " _
& "FROM qry_DOM_ProviderLookup_ByContract_CofC RIGHT JOIN tbl_DOM_Diaries ON qry_DOM_ProviderLookup_ByContract_CofC.careID=" _
& "tbl_DOM_Diaries.lkupTypeOfService WHERE (((qry_DOM_ProviderLookup_ByContract_CofC.nProviderID) Like " _
& [nProviderID] & ") AND ((qry_DOM_ProviderLookup_ByContract_CofC.nBlockRef)= Int(ReturnBlockRefFromSwift(" & [nSwiftID] _
& "))) AND ((tbl_DOM_Diaries.nDomBookingID) Like " & [anBookingID] & ") AND ((tbl_DOM_Diaries.lkupDomProviderName) Is Null));"
the piece in red is where it gets this value from. but the string it gets should just be inserted in the field (txtContactName) on the table.
EXTRA: If I remove the fields which cause this issue, I end up with error 3129 "invalid SQL satement, expected "DELETE", "INSERT",etc". What am I doing wrong?
for example, if I had typed "Fred" in [txtContactName], then the following would show: (kinda looks like)
inputbox("Fred","Enter Parameter Value")
the sql I am trying to run is:
"INSERT INTO tbl_DOM_ProviderContacts ( nProviderID, nBlockNumber, nDiaryID, lkupProviderBlockType, anBookingID," _
& "curPackageCost, dteDateOfContact, dteTimeOfContact, txtContactName, lkupContactOutcome, curTSA_Cost )" _
& "SELECT qry_DOM_ProviderLookup_ByContract_CofC.nProviderID, qry_DOM_ProviderLookup_ByContract_CofC.nBlockRef, " _
& "tbl_DOM_Diaries.anDiaryID, qry_DOM_ProviderLookup_ByContract_CofC.anContractTypeID, tbl_DOM_Diaries.nDomBookingID, " _
& "qry_DOM_ProviderLookup_ByContract_CofC.nContractedCost, Date() AS Expr1, Time() AS Expr2, " & [txtContactName] _
& " AS Expr3, " & [lkupContactOutcome] & " AS Contactoutcome," & [curTSA_Cost] & " AS TSA " _
& "FROM qry_DOM_ProviderLookup_ByContract_CofC RIGHT JOIN tbl_DOM_Diaries ON qry_DOM_ProviderLookup_ByContract_CofC.careID=" _
& "tbl_DOM_Diaries.lkupTypeOfService WHERE (((qry_DOM_ProviderLookup_ByContract_CofC.nProviderID) Like " _
& [nProviderID] & ") AND ((qry_DOM_ProviderLookup_ByContract_CofC.nBlockRef)= Int(ReturnBlockRefFromSwift(" & [nSwiftID] _
& "))) AND ((tbl_DOM_Diaries.nDomBookingID) Like " & [anBookingID] & ") AND ((tbl_DOM_Diaries.lkupDomProviderName) Is Null));"
the piece in red is where it gets this value from. but the string it gets should just be inserted in the field (txtContactName) on the table.
EXTRA: If I remove the fields which cause this issue, I end up with error 3129 "invalid SQL satement, expected "DELETE", "INSERT",etc". What am I doing wrong?