Coding so that query outcome effects main form (1 Viewer)

PaulA

Registered User.
Local time
Today, 16:16
Joined
Jul 17, 2001
Messages
416
Hi, all - here's the deal:

I have a subform in a main form that is a log. I would like a query that provides a value of the most recent entry to impact the main form. I have a query "qryRefStatus_Max" that basically provides the most recent entry of the log. The trick is pulling the value of that query for a particular patient so that certain fields are hidden and others appear depending on the status of that patient. Come patients have no records at all in the subform.

This is what I have done for code (and be gentle as I am not much of a coder):

Code:
If DCount("RefStatus", "qryRefStatus_Max", "[PtID]=" & Me.PtID) = 0 Then
Me.SuitLtrSubmit.Value = ""
Me.BypassLtrSubmit.Value = ""
Me.SuitLtrSubmit.Visible = False
Me.BypassLtrSubmit.Visible = False
Me.txtRefStatus.Value = ""
Exit Sub
End If
MaxRefStatus = DLookup("RefStatus", "qryRefStatus_Max", "[PtID]=" & Me.PtID)
If MaxRefStatus = "Denied" Then
Debug.Print "Its OK"
Forms![frmDatabaseMainNavigation]![navClinical Data]![SuitLtrSubmit].Visible = False
Forms![frmDatabaseMainNavigation]![navClinical Data]![BypassLtrSubmit].Visible = True

Else
Forms![frmDatabaseMainNavigation]![navClinical Data]![SuitLtrSubmit].Visible = True
Forms![frmDatabaseMainNavigation]![navClinical Data]![BypassLtrSubmit].Visible = False
End If

Any assistance would be appreciated!
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:16
Joined
Jan 23, 2006
Messages
15,379
Form and subform construct is used typically to show records from tables that are related in a 1 to Many relationship.
Perhaps you could describe what your tables and database represent in plain English. We need some context if we are to understand your set up and requirement.
 

PaulA

Registered User.
Local time
Today, 16:16
Joined
Jul 17, 2001
Messages
416
Actually, sorry for the confusion.

I found a much simpler way of getting what i want.

Thanks for replying.
 

Users who are viewing this thread

Top Bottom