Using Active X Calendar in query

B

Broadbonian

Trying to use a make table query. Would like to use starting date in the
form, then increment by 1, 2 ect..to get Monday-Sat dates. Get "Data type
mismatch in query expression". Can anyone help? Thanks
SELECT Forms!frmDates!startdate AS Sun, Forms!frmDates!startdate+1 AS Mon
INTO test;
 
D

Douglas J. Steele

Not sure whether it'll work, but try

SELECT CDate(Forms!frmDates!startdate) AS Sun,
CDate(Forms!frmDates!startdate)+1 AS Mon INTO test;

Of course, your table isn't normalized, so you might want to reconsider what
you're doing.
 
B

Bob Barrows [MVP]

Broadbonian said:
Trying to use a make table query. Would like to use starting date in
the form, then increment by 1, 2 ect..to get Monday-Sat dates. Get
"Data type mismatch in query expression". Can anyone help? Thanks
SELECT Forms!frmDates!startdate AS Sun, Forms!frmDates!startdate+1 AS
Mon INTO test;

Two things:
1. Be explicit: Forms!frmDates!startdate.value <--

2. You will likely need a PARAMETERS clause to tell Access to apply the
proper datatype to the value from the form control:
PARAMETERS Forms!frmDates!startdate.value DateTime;
SELECT ...
 
B

Broadbonian

That's exactly what I needed. Thank You
--
Darc


Douglas J. Steele said:
Not sure whether it'll work, but try

SELECT CDate(Forms!frmDates!startdate) AS Sun,
CDate(Forms!frmDates!startdate)+1 AS Mon INTO test;

Of course, your table isn't normalized, so you might want to reconsider what
you're doing.
 

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

Top