Form

A

AC

I have a Form that's based on a query. (only those that has a blank date on
the data field). Is it possible to create a button of some sort, that when i
click it, it will input today's date in the blank field?

I am trying to track some paperwork through my desk (eventually others).
This will help us track to see how long for us to process the paperwork. One
form will be date in the inbox, and another will be when it move out of my
desk. I am thinking this will make it easier than to type in the date each
time.

Thank you!!
 
B

Beetle

The Date() function will return the current date, so
in the Click event of the command button put;

Me![MytextBox] = Date()
 
J

John W. Vinson

I have a Form that's based on a query. (only those that has a blank date on
the data field). Is it possible to create a button of some sort, that when i
click it, it will input today's date in the blank field?

Sure. Put code like this in the command button's Click event:

Private Sub cmdToday_Click()
Me!datecontrolname = Date
End Sub

If you use Now rather than Date it will fill in the current date and time
instead of just the date.

I'll often put the same code in the textbox's DoubleClick event so the user
can just clickclick in the textbox and have the date fill in.
 
A

AC

Thank you for all your answer. I am still newbie to Access, and not sure
about VBA yet.

Should i create the form almost looking like a excel sheet (list of invoices
for example to pick from). If so, how can i make the event (macro?) to only
input the date on exact invoice that i click on? will it not put the date in
all of them?
 
B

Beetle

There are several ways you can design forms. It just depends on
what you or the users want to see. One of the design options is
called Datasheet, which looks a bit like a spread sheet, but since
you want to add your own command button to the form, you won't
be able to use the Datasheet design option. However, you can design
a Continuous form to look like a datasheet and have your own
command button on the form.

The code examples we provided earlier would only affect the
current record, not every record in the table. You would put
that code in the Click event of the command button. To do this
you woould open the properties sheet for the command button,
go to the Events tab, find the On Click event and click the build
(...) button at the right side of that line. Then select Code Builder
and the code window will open with the following lines
already there;

Private Sub YourButton_Click ()

End Sub

you would then put the line of code in between those lines, go to
Debug/Compile (just to check for typos), click the Save button and
close the code window. Then test your command button to make
sure it does what you want.
 
A

AC

OMG!!! It works. Thank you so much!!!

My next question is... (sorry). it work when i connect the form to the
table, but when i try to do it with query (I only want the blank to show up),
it will either put the date in all of them, or error message that say
"qualifier must be a collection"

Thanks again!!
 
J

John W. Vinson

My next question is... (sorry). it work when i connect the form to the
table, but when i try to do it with query (I only want the blank to show up),
it will either put the date in all of them, or error message that say
"qualifier must be a collection"

Please post your actual code, and probably also the SQL view of your query.
 

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