Form error "Type Mismatch"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

In my time tracking db, I have a hidden form that opens immediately after
the switchboard "fWorkLogHidden". If someone forgot to log out of the db (by
filling in StopTime) the previous day, there is another form
"fWorkLogPreviousDay" that opens from the FormLoad event of the hidden form,
requiring stop time to be filled in the next time the db opens.
Below is code I currently have in place, but get error "13 Type Mismatch".

DoCmd.OpenForm "fWorklogpreviousday", acNormal, , "stoptime isnull" And
"starttime BETWEEN Date() and (Date() - 1)"

I know this is not right, but I've been going round and round with this code
trying to make it work and decided to post for help. What I want to happen
is for the PreviousDay form to open records where the StartTime is the day
before and the StopTime is empty. Originally, I had the query that backs
this form set to StartTime = Date()-1 and StopTime IsNull. I read about form
filters so I removed the criteria from query and set the "Allow Filters" to
Yes.

I hope this makes sense and that someone will have answer to make this work
as I want it to. Any help is greatly appreciated.
Thanks,
Pam
 
I think it is just a syntax problem

DoCmd.OpenForm "fWorklogpreviousday", acNormal, , "stoptime isnull" And
"starttime BETWEEN Date() and (Date() - 1)"

Try
"stoptime Is Null And starttime BETWEEN #" & Date() -1 & "# AND #" &
Date() & "#"
 
On the off chance that the user has his/her Short Date format set to
dd/mm/yyyy, the following would be safer:

"stoptime Is Null And starttime BETWEEN " & Format(Date() -1,
"\#yyyy\-mm\-dd\#") & " AND " &
Format(Date(), "\#yyyy\-mm\-dd\#")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Error 2465 6
View Records for Editing Only 1
Unload Event Problem 12
screen updating problem 0
counting time 1
Method of Data Member Not found 6
Locking Records 2
how to call function 3

Back
Top