Help with If statement

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

Guest

I have a command button that when clicked, it brings up an input box. The
user has to put in a date (mm/dd/yyyy). I need an If statement that searches
the column, if the date typed in is in the column, of course it will bring up
the data. But if the date is not in the column, I need another input box to
come up that reads, 'Date not found, try again.' If the user doesn't want to
try again, then a command button to close the input box. (I'm not sure, but
that command button may be a default button)

Here is what I have to pull the correct date:

SELECT *
FROM tblInvLog
WHERE InvDt=[What is the invoice date? (mm/dd/yyyy)];

But again, I need an If statement that tells the user the date was not
found. Right now, if the date is not found, it still brings up the table, but
with no data.

Anybody have any ideas?

Thanks
 
Do your users a favor and use a control on a form to enter the date. You can
then check to make sure the date is in the report's record source prior to
attempting to open. Otherwise use the On No Data event of the report to
display a message and close the report.
 
Hi Duane,

Thanks for the repsonse, but the users' response isn't going on a report.
It's going on a form where the user can see all of the invoices that were
paid for that day, using the navigation buttons at the bottom of the form to
scroll through the invoices. I also wouldn't know what control to use, since
there will be so many invoice dates, (365 days x many years), I thought it
would just be easier instead of having to scroll through so many dates, to
just type in a date.

Duane Hookom said:
Do your users a favor and use a control on a form to enter the date. You can
then check to make sure the date is in the report's record source prior to
attempting to open. Otherwise use the On No Data event of the report to
display a message and close the report.

--
Duane Hookom
Microsoft Access MVP


Antney said:
I have a command button that when clicked, it brings up an input box. The
user has to put in a date (mm/dd/yyyy). I need an If statement that searches
the column, if the date typed in is in the column, of course it will bring up
the data. But if the date is not in the column, I need another input box to
come up that reads, 'Date not found, try again.' If the user doesn't want to
try again, then a command button to close the input box. (I'm not sure, but
that command button may be a default button)

Here is what I have to pull the correct date:

SELECT *
FROM tblInvLog
WHERE InvDt=[What is the invoice date? (mm/dd/yyyy)];

But again, I need an If statement that tells the user the date was not
found. Right now, if the date is not found, it still brings up the table, but
with no data.

Anybody have any ideas?

Thanks
 
Consider using the combo box wizard to create a combo box that finds a record
on your form. If you reference the invoice date as the row source of the
combo box, your users won't be able to enter a date that isn't in the table.

--
Duane Hookom
Microsoft Access MVP


Antney said:
Hi Duane,

Thanks for the repsonse, but the users' response isn't going on a report.
It's going on a form where the user can see all of the invoices that were
paid for that day, using the navigation buttons at the bottom of the form to
scroll through the invoices. I also wouldn't know what control to use, since
there will be so many invoice dates, (365 days x many years), I thought it
would just be easier instead of having to scroll through so many dates, to
just type in a date.

Duane Hookom said:
Do your users a favor and use a control on a form to enter the date. You can
then check to make sure the date is in the report's record source prior to
attempting to open. Otherwise use the On No Data event of the report to
display a message and close the report.

--
Duane Hookom
Microsoft Access MVP


Antney said:
I have a command button that when clicked, it brings up an input box. The
user has to put in a date (mm/dd/yyyy). I need an If statement that searches
the column, if the date typed in is in the column, of course it will bring up
the data. But if the date is not in the column, I need another input box to
come up that reads, 'Date not found, try again.' If the user doesn't want to
try again, then a command button to close the input box. (I'm not sure, but
that command button may be a default button)

Here is what I have to pull the correct date:

SELECT *
FROM tblInvLog
WHERE InvDt=[What is the invoice date? (mm/dd/yyyy)];

But again, I need an If statement that tells the user the date was not
found. Right now, if the date is not found, it still brings up the table, but
with no data.

Anybody have any ideas?

Thanks
 
Thanks Duane.

Duane Hookom said:
Consider using the combo box wizard to create a combo box that finds a record
on your form. If you reference the invoice date as the row source of the
combo box, your users won't be able to enter a date that isn't in the table.

--
Duane Hookom
Microsoft Access MVP


Antney said:
Hi Duane,

Thanks for the repsonse, but the users' response isn't going on a report.
It's going on a form where the user can see all of the invoices that were
paid for that day, using the navigation buttons at the bottom of the form to
scroll through the invoices. I also wouldn't know what control to use, since
there will be so many invoice dates, (365 days x many years), I thought it
would just be easier instead of having to scroll through so many dates, to
just type in a date.

Duane Hookom said:
Do your users a favor and use a control on a form to enter the date. You can
then check to make sure the date is in the report's record source prior to
attempting to open. Otherwise use the On No Data event of the report to
display a message and close the report.

--
Duane Hookom
Microsoft Access MVP


:

I have a command button that when clicked, it brings up an input box. The
user has to put in a date (mm/dd/yyyy). I need an If statement that searches
the column, if the date typed in is in the column, of course it will bring up
the data. But if the date is not in the column, I need another input box to
come up that reads, 'Date not found, try again.' If the user doesn't want to
try again, then a command button to close the input box. (I'm not sure, but
that command button may be a default button)

Here is what I have to pull the correct date:

SELECT *
FROM tblInvLog
WHERE InvDt=[What is the invoice date? (mm/dd/yyyy)];

But again, I need an If statement that tells the user the date was not
found. Right now, if the date is not found, it still brings up the table, but
with no data.

Anybody have any ideas?

Thanks
 

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

Back
Top