Runtime error 13

rexb

Registered User.
Local time
Today, 12:01
Joined
Oct 29, 2008
Messages
129
I've got this code, once it updates it would give me a run-time erro '13' type mismatch

date_completed is a date

Here is the code:

Private Sub cboStatusId_AfterUpdate()
If cboStatusId.Value = 1 Then
Me.txtDateCompleted.Visible = True
Me.txtDateCompleted = Now(date_completed)
Else
Me.txtDateCompleted.Visible = False

End If

End Sub
 
On what line? For starters, this should be:

Me.txtDateCompleted = Now()
 
4th line
- Me.txtDateCompleted = Now(date_completed)

how do I save the "now()" to the field if i am not to put "date_completed"?
 
As long as that textbox is bound to the field, the syntax I posted will save the value. The Now() function does not accept an argument in the parentheses.
 
But the date will change every time you open it right? What I want is when I choose cboStatusId.Value = 1 it should be completed and save the date and after that it shouldn't be edited anymore or the date shouldn't change at all.
 
You can add a test so it will only populate it once:

Code:
If IsNull(Me.txtDateCompleted) Then
  Me.txtDateCompleted = Now() 
End If
 
I tried the code. but when I changed the date on the computer the date changed also.
 
What is your full code now?
 
rivate Sub cboStatusId_AfterUpdate()
If cboStatusId.Value = 1 Then
Me.txtDateCompleted.Visible = True

If IsNull(Me.txtDateCompleted) Then
Me.txtDateCompleted = Now()
End If
Else
Me.txtDateCompleted.Visible = False

End If

End Sub
 
That should only add the date the first time the status is 1. You're saying it will change the date after that? Can you post the db?
 
I think I got it right thanks. I had a now() on on focus of the form. I just deleted that.
 

Users who are viewing this thread

Back
Top Bottom