|
-
Jan 18th, 2000, 03:03 PM
#1
Thread Starter
Member
I have the following querry where i want to save my values from my textboxes back into my database:
'Declare our variables
Dim dbProgram As New ADODB.Connection
Dim rsMain As New ADODB.Recordset
'Open our connection
dbProgram.Open "dsn=Program"
'build the sql update query
sql = "update Main set " & _
"Job_No = '" & txtJob.Text & "', " & _
"Cust = '" & txtCust.Text & "', " & _
"Site = '" & txtSite.Text & "', " & _
"Order_No = '" & txtOrder.Text & "', " & _
"Model = '" & txtModel.Text & "', " & _
"Prefix = '" & txtPrefix.Text & "', " & _
"Serial = '" & txtSerial.Text & "', " & _
"SMR = '" & nonulls(txtSMR.Text) & "', " & _
"DateOpen = '" & txtDateOpen.Text & "', " & _
"DateClosed = '" & txtDateClosed.Text & "', " & _
"DateStart = '" & txtDateStart.Text & "' , " & _
"DateEnd = '" & txtDateEnd.Text & "' , " & _
"Status = '" & chkStatus.Value & "' , " & _
"Remarks = '" & txtRemarks.Text & "'where idJob = " & _
intCurrJob
'execute the query
dbProgram.Execute sql
It work fine but if i have empty textboxes i get an error.(Type mismatch)
My ACCESS database has the following data types:
Text >(strings) OK I used allow zero lenght
Number & Date/Time > Problem when saving empty values into database i get a type mismatch error.
If you see my querry above at the text box SMR i use the following function:
Function nonulls(s As Variant) As String
If IsNull(s) Or Len(s) = 0 Then
nonulls = ""
Else
nonulls = s
End If
End Function
It does not want to work ,but if i want to replace an empty string with a zero it does work.
ps: I want to keep my textboxes empty and I am using a masked edit control for my dates.
So can anybody help me!! Is there a way to save empty textboxes(integers or longs and dates) into an database. 
Thanks !!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|