forms using input (Query) and reports to print

jairg

New member
Local time
Yesterday, 16:35
Joined
Apr 17, 2017
Messages
4
Hi,
I'm new here and I have not been able to locate the answer for my puzzle:

I have a table (Table1) with fields: ID (key), First Name, Last Name, Timestamp, Period, Counter

I have a Select Query (look up) with Criteria using Text0 from Form (Action):
[Forms]![Action]![Text0]

My Form (Action) has an input field to locate the record. What I am trying to accomplish is the following:

Enter Record ID (key) and upon enter or tab:

Locate the Record
If [record's Timestamp field] is empty (null?) Then [do not print report]

Else [Print Report]**

** I print report using: DoCmd.OpenReport "Print Label", acViewNormal, "", "", acHidden

Print Label Report Property Sheet has Data-Record Source: Look up (Query)

In the report after user has input the ID, I cannot figure out how to run the conditional to check for Timestamp value and according to the value either popup a MsgBox ("error no date") or juts print the label

The worst part is that I did it about 4 years ago, but I cannot remember :(
 
Thanks, Dlookup did the trick... I didn't use it before, but it works just fine, now I know another way of doing this (well I know only one, as I forgot the other :))

One more question, now the events run when a command is clicked, how can I bypass that click and use Enter from the textbox? in other words when user clicks enter in the keyboard while in the textbox, run the Code attached to the Command (or maybe move the code to the textbox?)

Thanks!
 
Try moving the code to the after update event of the textbox.
 
yes, I have tried that and nothing happens, literally, nothing.. I removed the command box, should I leave it there?

I have also tried key down and that one acts strange... I used it with

If KeyCode = 13 Then

it gets the values requested (runs code), but if another value is entered in text0 then I need to click twice... first to get previous and then to get the actual...
 
I am sorry, I didn't explain... yes I copy-paste the code to the new event for the textbox.. and it just doesn't do anything at all
 
Can you attach the db here? Or post the code as it is now? Presuming the code is properly associated, it should run when the user hits enter or tab.
 

Users who are viewing this thread

Back
Top Bottom