empty field in eepoet (1 Viewer)

Dick7Access

Dick S
Local time
Today, 10:02
Joined
Jun 9, 2009
Messages
4,197
googling this could not come up with an answer one way or the other. Just experimenting. Is it possible to use VBA with a report or is there something wrong with my code?
Code:
'FOOD/DRINK REPORT
Private Sub activity_GotFocus()
If Me.activity.Text = "food/drink" Then
Me.Fooddrink.Visible = True
End If
End Sub
 

isladogs

MVP / VIP
Local time
Today, 14:02
Joined
Jan 14, 2017
Messages
18,186
googling this could not come up with an answer one way or the other. Just experimenting. Is it possible to use VBA with a report or is there something wrong with my code?
Code:
'FOOD/DRINK REPORT
Private Sub activity_GotFocus()
If Me.activity.Text = "food/drink" Then
Me.Fooddrink.Visible = True
End If
End Sub

If you open a report in Report View then it is possible to have user interaction e.g. click a button or hyperlink. However, I've never tried code like you have above.

However no interaction is possible in Print Preview
 

Dick7Access

Dick S
Local time
Today, 10:02
Joined
Jun 9, 2009
Messages
4,197
As I said previously my finish report generator for my doctor works ok. However, I showed several finished printed reports changing the color scheme to see what color combination people thought was the most eye appealing. One person said instead of showing nulls marked N/A for some fields

EXAMPLE: sugar: 120, / Sytolic N/A / Diastolic N/A / Pulse N/A / weight N/A
Why not
print a report showing each date with only the fields with data and not showing the fields with no data at all.
EXAMPLE: sugar 120

That got me to thinking how to do that. I first threw together a simple form and put in a few fields and put visible as no in the property sheet. I then coded the activity field with the following VBA code.
'CHECK SUGAR
Private Sub activity_GotFocus()
If Me.activity.Text = "check sugar" Then
Me.bloodSugar.Visible = True
End if
End sub
Worked great, so I threw together a quick report. Code as previously mentioned didn’t work.
Anybody have a suggestion as how to achieve the one field per line report?
 

isladogs

MVP / VIP
Local time
Today, 14:02
Joined
Jan 14, 2017
Messages
18,186
This worked for me using your rpt3Months in report view

Code:
Private Sub activity_GotFocus()
If Me.activity = "check sugar" Then
    Me.bloodSugar.Visible = True
Else
   Me.bloodSugar.Visible = False
End If
End Sub

You don't need .Text as the value is already saved. Nor 'Value as that's the default property

Remember it won't work in Print Preview

I did find it rather distracting however. But its your report not mine
Of course using a report like that one with multiple records, either all Sugar values are shown or none depending on what activity value you click
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 14:02
Joined
Jan 14, 2017
Messages
18,186
Try the attached
Click on the word Check Sugar in the Activity field ...not the Activity header label
Then click another value in the same field
 

Attachments

  • DicksvitalsVer1_2.zip
    109.9 KB · Views: 77

Dick7Access

Dick S
Local time
Today, 10:02
Joined
Jun 9, 2009
Messages
4,197
Try the attached
Click on the word Check Sugar in the Activity field ...not the Activity header label
Then click another value in the same field

Interesting concept. It might be a start. I see where you coded the activity field as a cmd to make the blood field to bring up the data, so the VBA works as cmd but the other fields are still visible, plus I need it to work dynamically so that when it prints only the fields with data will show. Could be a start, however. Can you elaborate on where you think this might lead?
 

isladogs

MVP / VIP
Local time
Today, 14:02
Joined
Jan 14, 2017
Messages
18,186
I thought I was just coding what you had tried....????

Its not something I've ever considered before but if you post your version with the report you want to use, and tell me what you want to see, I'll tweak it and hopefully achieve that goal
 

June7

AWF VIP
Local time
Today, 06:02
Joined
Mar 9, 2014
Messages
5,423
I thought you were trying to set visibility of controls on form. This can be done in a report. Code would be in Detail section Format event for dynamic display per record but only executes direct to printer or PrintPreview, not Report view

Didn't displaying N/A resolve this issue?

Conditional Formatting can set backcolor, not bordercolor. So if borders were transparent then CF could set background to white when there is no data (or field has N/A) and field would have appearance of not visible. This will work in Report or Print views. If field has N/A, also use an expression in textbox: =IIf(fieldname="N/A", Null, fieldname). But then maybe should go back to not saving N/A and could use number type field for quantitative data.

I find all that color coding rather distracting. Keep in mind if report is copied in B&W, colors will be lost and boxes various shades of grey which can make reading values harder.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 14:02
Joined
Jan 14, 2017
Messages
18,186
VBA code does work in report view as previously stated.
Much of it will not work in print preview e.g. Click or got focus events...again as previously stated
 

June7

AWF VIP
Local time
Today, 06:02
Joined
Mar 9, 2014
Messages
5,423
Sorry, I meant for automatic dynamic display per record without user interaction, code must be in Detail Format event and only works for print or PrintPreview.

If you want user interaction, that's what forms are for.
 

isladogs

MVP / VIP
Local time
Today, 14:02
Joined
Jan 14, 2017
Messages
18,186
User interaction is also what Report View is for.
Though I rarely use it, report view does have benefits including button and hyperlink clicks as well as possible uses such as Dick is suggesting.
 

June7

AWF VIP
Local time
Today, 06:02
Joined
Mar 9, 2014
Messages
5,423
I agree, one can be made to work somewhat like the other. I have used a form for printing and displayed a report on a form. If OP wants something that can be printed for distribution to doctor or patient, will have to be report Print and code in Format event.
 

Dick7Access

Dick S
Local time
Today, 10:02
Joined
Jun 9, 2009
Messages
4,197
I want to merge data from two tables into 1 table. (same DB) (same field names) (different data) but some have same ID numbers. What kind of query should I use?
 

June7

AWF VIP
Local time
Today, 06:02
Joined
Mar 9, 2014
Messages
5,423
Do these tables have related dependent tables?

Can use a UNION query for temporary 'merge' but if you went them in a new table with ID as unique identifier, will have to create new ID field and associate dependent records with that new ID. Gets tricky.
 

Dick7Access

Dick S
Local time
Today, 10:02
Joined
Jun 9, 2009
Messages
4,197
no they are stand alone tables. thanks I will study Union queries.
 

Dick7Access

Dick S
Local time
Today, 10:02
Joined
Jun 9, 2009
Messages
4,197
Do these tables have related dependent tables?

Can use a UNION query for temporary 'merge' but if you went them in a new table with ID as unique identifier, will have to create new ID field and associate dependent records with that new ID. Gets tricky.

Thanks again, Union query worked well!
 

Users who are viewing this thread

Top Bottom