Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying for records with a checkbox 2

Status
Not open for further replies.

Brlee1crv

Technical User
Apr 10, 2003
96
0
0
US
Greetings,
I have a job form that contains a checkbox. The checkbox is for whether or not a particular job has been reviewed. Is it possible to add a textbox next the checkbox to show when the record was reviewed (timestamp)? If so how do I go about doing this?

Basically I would like to be able to query which records were reviewed on a particular day. Thanks in advance.
 
How are ya Brlee1crv . . . . .

In order to maintain the timestamp you need to [blue]add a field to the table.[/blue] Select General Date for the format (this includes date & time in the stamp)

Then make sure the new field is included in the [blue]RecordSource[/blue] for the form.

Finally add a bound control to the form for it.

Next in the AfterUpdate event of the CheckBox add the following code (you substitute proper names in [purple]purple[/purple]):
Code:
[blue]   If Me![purple][b]CheckBoxName[/b][/purple] Then
      Me![purple][b]TextBoxName[/b][/purple] = Now()
   Else
      Me![purple][b]TextBoxName[/b][/purple] = ""
   End If[/blue]
Note: Its too easy and inviting to click the box, overwriting the previously saved stamp. You may want to consider disabling the checkbox for those records with saved stamps.

Thats it . . . give it a whirl and let me know . . .


Calvin.gif
See Ya! . . . . . .
 
Thanks AceMan1!!

I added the field ReviewStamp to the recordsource table and added the field to the form. I added the code in the AfterUpdate event (substituting names). However when I try the form out by clicking on the checkbox nothing appears in the ReviewStamp field. Help!!
 
Brlee1crv . . . . .

I believe you put the code in the wrong place . . .

Call up the properties for the checkbox. Delete/remove what ever is on the [blue]event line[/blue]. Make sure the cursor is on the event line, the click the [blue]three elispes[/blue] just to the right. Thats where the code goes. When your done it should look like this:
Code:
[blue]Private Sub CheckBoxName_AfterUpdate()
   
   If Me!CheckBoxName Then
      Me!TextBoxName = Now()
   Else
      Me!TextBoxName = ""
   End If

End Sub[/blue]
Also, if [blue]any of the names have spaces[/blue] in them, surround them with brackets: [blue][Review Stamp][/blue]
As a test, type a date in the textbox first, then try the checkbox.

Let me know how ya make out . . .

Calvin.gif
See Ya! . . . . . .
 
Thanks for all your help AceMan!!!

If I want to use a combobox to timestamp the textbox field how can I go about doing this? For instance I have a combobox that has a status of Completed and Assigned. If Completed is selected the textbox will be timestamped. Thanks again for your assistance.
 
Brlee1crv . . . .

In the AfterUpdate event of the combobox copy/paste the following:
Code:
[blue]   If Me![purple][b]ComboBoxName[/b][/purple] = "Completed" Then
      Me!TextBoxName = Now()
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks. I tried that but nothing happens after I select Completed.
 
OK Brlee1crv . . . . .

It sounds like [blue]Completed[/blue] is in a certain field in the combobox. Try this:
Code:
[blue]   If Me!ComboBoxName.Column(1) = "Completed" Then
      Me!TextBoxName = Now()
   End If[/blue]
You may have to play with the Column number a little. Just remember column count starts at zero on the left and includes any fields set to zero width.

Calvin.gif
See Ya! . . . . . .
 
Yay!! That was it. Thanks for you help. You da man.
 
AceMan1,
I am trying to create a query for dates now but I can't get results. For criteria I am used Date() under the ReviewStamp field but nothing comes up when I run it. I also tried entering a specific date such as 10/20/2004 but I don't get results either. I would like for someone to select a date or date range and be able to view all entries that were reviewed based on the time stamp.
 
Brlee1crv . . . . .

I have a few other posts to catch up on that could take some time.

Start a new post and I'll stop by when I'm done. This way others will benefit more from the help you receive.

Besides . . . . there's a great number of guru's here!

Calvin.gif
See Ya! . . . . . .
 
Seems your ReviewStamp field contains full DateTime value (ie updated with Now() instead of Date()).
You work out this with something like this:
WHERE .... Int(ReviewStamp)=Int(Date()) ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top