Updating Date field from a textbox

MarkItZero

Active member
Joined
Apr 10, 2003
Messages
43
Location
under the desk in my office
Hello,
I am trying to update a Date field in an Access database by reading the value from a text box on my form. The user enters the value on the form and clicks the Update button.

However when I attempt to run the program, I get an error after clicking the Update button that says Type Mismatch.

So I am guessing that this means I need to perform some sort of datatype conversion before attempting the update.

Rst1 is my Recordset
DateUpdate is a variable I use to hold the text boxs value
txtDate is the Text box containing the value to be updated

Here is the code I have so far...

Code:
Load Current Date Value
txtDate.Text = CStr(rst1("Date").Value)

Set New Value to DateUpdate Variable
DateUpdate = txtDate.Text

Private Sub CmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdBack.Click
        
        rst1.Fields("Date").Value = " & DateUpdate & "
        rst1.Update()

End Sub

Any suggestions?

Thanks!
 
I figure out my problem....

I assigned the DateUpdate var in the wrong place and I my a had bad syntax on the update expression.

This is the working code..

Code:
Load Current Date Value
txtDate.Text = CStr(rst1("Date").Value)

Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
        Assign Update Vars
        DateUpdate = txtDate.Text

        Update Fields
        rst1.Fields("Date").Value = DateUpdate
        rst1.Update()
    End Sub

Good day
 
Back
Top