OnOpen Criteria

taenite

Registered User.
Local time
Today, 15:16
Joined
Jun 26, 2001
Messages
13
I was hoping any of you could put me on the right track to figuring out this code:

Private Sub LateRecords_Click()
On Error GoTo LateRecords_Click

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FormProvisionstoFollow"
If [FormProvisionstoFollow].[Ackn_of_Receipt_Due] < Now() Then
If IsNull([FormProvisionstoFollow].[Date Received]) Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

Exit_LateRecords_Click:
Exit Sub

Err_LateRecords_Click:
MsgBox Err.Description
Resume Exit_LateRecords_Click

End Sub

All its basically saying is when command button "laterecords" is clicked, Form "FormProvisionstoFollow" will open, but only the records where [FormProvisionstoFollow].[Ackn_of_Receipt_Due] < Now() and IsNull([FormProvisionstoFollow].[Date Received]). I know im way off track. Please help me : )

Thank you all.
 
You have not assigned a value to the criteria string.

Dim stLinkCriteria As String
stLinkCriteria = ???

I also count to IFs but only one END IF. Your sub should error because of that.

HTH
 
Quick Post:

i) You can't check a value on a form before you open it;

ii) You only have one End If statement;

iii) stLinkCriteria is redundant in this case.
 
Ok, I fixed the end if problem. Now it gives me a label error.

If you cant check a value on a form before you open it, then how do you open forms with specific criteria?

I dont define link criteria, because there is nothing that links the current form to the one I am opening. The current form is nothing but a main menu.

Someone mentioned using openargs, but I havent found any information that has helped me understand how to use that function.
 
As you can't check a value on the form (as it is not opened and, therefore, neither is its underlying recordset) then the process you'll have to take is to evaluate the value in the fields of said underlying recordset.

You'll be best served by looking up domain aggregate functions in the help to find such 'wonders' as DLookup() and DCount().

Also, to see where your code is going wrong, comment out the line: On Error Goto....
 
ok. i did some research on Dlookup.

Currently my form has a code that calculates the date difference between two date fields and displays in a label "overdue" or "on schedule"

It looks as though Dlookup can only look up a single table value. Im looking up what a label says in a form and returning the entire record within the form. I dont think thats possible through dlookup. (?)

I could be wrong. ...but Im rather lost again on how to go about doing this.... :-/

any further info would be wonderful.

Thanks again.
 
Trust me, I would LOVE to do that...to me that makes sense, but I be a simple mind when it comes to access, and the gurus say that is not possible : ) But then, perhaps you are a guru...so enlighten me if you will! How can i code the where function in to work?

Thanks : )
 
Off the top of my head something like
DoCmd.OpenForm stDocName, , , "[Ackn_of_Receipt_Due] < Date And IsNull([Date Received])"
 

Users who are viewing this thread

Back
Top Bottom