Randall Anthony
randall.anthony at cox.net
Sat Jan 26 16:03:49 CST 2008
Gotcha! I was trying to work within the bounds of the existing code and didn't explore alternatives to that. Since I am passing the openargs, why not include the criteria (which can be multiple coming from form A) as in proposed solution b and c? I'm tired of looking at it today, but I think I'll explore those ideas tomorrow and report back posthaste. Thanks Steve, and everyone else for your help. -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Steve Schapel Sent: Saturday, January 26, 2008 4:39 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Cannot set recordsource on Load Event Randall, Ah, now I see what you mean. You are using a Where Condition in your OpenForm method. I sorta didn't notice that before. Yes, subsequently setting the Record Source property will obviously overwrite the Where Condition previously applied. Ok, as a concept, here's how I would do it: Form A DoCmd.OpenForm "Audit Entry", , , , , , "1" Form B Private Sub Form_Open(Cancel As Integer) If Me.OpenArgs = "1" Then Me.RecordSource = "SELECT * FROM Audit_Data_Med WHERE <your criteria>" Else Me.RecordSource = "Audit_Data_MH" End If End Sub Hard to shoot in the dark here, without knowing what the mysterious Criteria is all about. But it could be that this is more applicable concept: Form A DoCmd.OpenForm "Audit Entry", , , , , , Criteria Form B Private Sub Form_Open(Cancel As Integer) If Len(Me.OpenArgs) Then Me.RecordSource = "SELECT * FROM Audit_Data_Med WHERE " & Me.OpenArgs Else Me.RecordSource = "Audit_Data_MH" End If End Sub ... Or: Form A DoCmd.OpenForm "Audit Entry", , , , , , "1" & Criteria Form B Private Sub Form_Open(Cancel As Integer) If Me.OpenArgs Like "1*" Then Me.RecordSource = "SELECT * FROM Audit_Data_Med WHERE " & Mid(Me.OpenArgs, 2) Else Me.RecordSource = "SELECT * FROM Audit_Data_MH WHERE " & Me.OpenArgs End If End Sub Regards Steve Randall Anthony wrote: > I sorry I didn't make myself clear. I have also just placed a line of code > in the OpenForm event Me.Recordsource = "Audit_Data_Med" and it still > returns all records. > > Could setting the criteria be the problem? That I can't apply a filter to > the form while dynamically setting the recordsource? -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com