wrapping these code

icemonster

Registered User.
Local time
Today, 13:37
Joined
Jan 30, 2010
Messages
502
so yeah, this may sound silly to some but how would you split the lines for this mysql statement?

Code:
strSQL = "UPDATE tbl_student SET " & _
                                   "student_lastname = '" & Me.txtlastname & "', student_firstname = '" & Me.txtfirstname & "', student_gender = '" & Me.cbogender & "', student_birthdate = '" & Me.dtdobconv & "', student_ethnicity = '" & Me.cboethnicity & "', student_ssn = '" & Me.txtssn & "' " & _
                                    "WHERE id_student = " & Me.txtstudentid & ";"     ' 
                          .Execute strSQL, , adCmdText + adExecuteNoRecords

thanks guys
 
like so that the sql statement isnt long, normally i would add a & _ at the end then " at the beginning of the new line, but for some reason it's not working :D (or maybe i just don't know how - this back end is mysql, diving into deeper waters here ;P)
 
Code:
strSQL = "UPDATE tbl_student SET " & _
                                   "student_lastname = '" & Me.txtlastname & _
                                       "', student_firstname = '" & Me.txtfirstname _
                                       & "', student_gender = '" & Me.cbogender & _
                                       "', student_birthdate = '" & Me.dtdobconv & _
                                       "', student_ethnicity = '" & Me.cboethnicity _
                                       & "', student_ssn = '" & Me.txtssn & "' " & _
                                    "WHERE id_student = " & Me.txtstudentid & ";"     
                          .Execute strSQL, , adCmdText + adExecuteNoRecords

like so, but with explanation cause the only reason i got this to work was because of mztools (for some reason their error trap doesn't seem to work, i purposely created an error and was directed to debug)
 
That's what I thought you meant, but wasn't sure. Anyway I too would have used "& _" to indicate a continuation, but as you are dealing with mysql, a quick google reveals that you need to us a \ to indicate a line continuation.

Another method would be to concatenate the lines as follows;
Code:
strSQL = "UPDATE tbl_student SET " 
strSQL = strSQL & "student_lastname = '" & Me.txtlastname & "', student_firstname = '" & Me.txtfirstname & "', student_gender = '" & Me.cbogender & "', student_birthdate = '" & Me.dtdobconv & "', student_ethnicity = '" & Me.cboethnicity & "', student_ssn = '" & Me.txtssn & "' "
strSQL = strSQL & "WHERE id_student = " & Me.txtstudentid & ";"     ' 
                          .Execute strSQL, , adCmdText + adExecuteNoRecords
 
oh yeah, didn't think of it that way. awesome thanks man.
 

Users who are viewing this thread

Back
Top Bottom