View Single Post
  #5 (permalink)  
Old November 14th, 2008, 08:21 AM
mmcdonal mmcdonal is offline
Friend of Wrox
Points: 9,516, Level: 42
Points: 9,516, Level: 42 Points: 9,516, Level: 42 Points: 9,516, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,060
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Are you reeeeealllyyyy just asking rhetorical questions to make you feel superior? Reeeeaaallly? What are you, 12? (He asked rhetorically)

Sorry Luis, sometimes people overlook the obvious. I apologize for Old Pedant's condescending post as well.

What he is saying is that you need to break the string to add the control values, and refer to the form fields by also referencing the form. I usually take the values into variables myself.

So:

sSQL = "INSERT INTO tbl-RmaNumberLog([ExpeditedOrder], [RmaCompanyName], [RmaStreetAdd1]," & _
"[RmaStreetAdd2], [RmaCity], [RmaState], [RmaZipCode], [RmaCountry]," & _
"[RmaTelephone], [RmaExt], [RmaFax], [RmaE-mail ], [RmaPONumber],[RecordCreator], [RmaNumber]" & _
"[RmaCarrierAcc], [NistCertification], [RmaNotes])" & _
" VALUES('[CheckExpeditedOrder]', '[TextRmaCompanyName]', '[TextRmaStreetAdd1]'," & _
"'[TextRmaStreetAdd2]', '[TextRmaCity]', '[TextRmaState]', '[TextRmaZipCode]', '[TextRmaCountry]'," & _
"'[TextRmaTelephone]', '[TextRmaExt]', '[TextRmaFax]', '[TextRmaE-mail]', '[TextRmaPONumber]'," & _
"'[TextRmaCarrierAcc]', '[CheckNistCertification]', '[TextRmaNotes]', VarUserName, NewRmaNumber)"


Should be more like:

sSQL = "INSERT INTO tbl-RmaNumberLog([ExpeditedOrder], [RmaCompanyName], [RmaStreetAdd1]," & _
"[RmaStreetAdd2], [RmaCity], [RmaState], [RmaZipCode], [RmaCountry]," & _
"[RmaTelephone], [RmaExt], [RmaFax], [RmaE-mail ], [RmaPONumber],[RecordCreator], [RmaNumber]" & _
"[RmaCarrierAcc], [NistCertification], [RmaNotes])" & _
" VALUES('" & Me.CheckExpeditedOrder & "', '" & Me.TextRmaCompanyName & "', '" & Me.TextRmaStreetAdd1 & "'," etc.

Normally I would do data validation on the form since I do a lot of Access / SQL and don't want to throw SQL Server errors at my users. So I would do this:

Dim sEOrder As Boolean
...

sEOrder = Me.CheckExpeditedOrder 'without validation here
...

sSQL = "INSERT INTO tblMyTable(Col1, Col2, Col3...) VALUES(" & sEOrder & ", " etc.

Did that help?

mmcdonal

Look it up at: http://wrox.books24x7.com
Reply With Quote