![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
On Wed, 5 Mar 2008 13:40:06 -0800 (PST), bobh wrote: Hi All, Has anyone figured out how to reset the recordsource of a openned form?? ex: User opens a form, selects a value from combo1, selects a value from combo2, in the AfterUpdate event of combo2 write the sql for the recordsource using those two choosen values then do a me.recordsource = strSQL me.requery or do I 'have' to do a form/subform for this thanks bobh. Yes, but I can't do it for you with the limited info you have given. Code the Combo AfterUpdate event something like: Dim strSQL as String strSQL = "Select ....blah, blah.." Me.RecordSource = strSQL Me.Refresh |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
IIRC, in a Form, you can change the RecordSource at the Open event or any time thereafter, and you do not have to requery, because changing the RecordSource causes the Form to be Requeried. *It would seem from your question that your experience differs... what are you observing? In Reports, OTOH, you can successfully change the RecordSource only in the Open event. *Larry Linson *Microsoft Office Access MVP |
#5
| |||
| |||
|
|
On Mar 6, 12:06 am, "Larry Linson" <boun... (AT) localhost (DOT) not> wrote: IIRC, in a Form, you can change the RecordSource at the Open event or any time thereafter, and you do not have to requery, because changing the RecordSource causes the Form to be Requeried. It would seem from your question that your experience differs... what are you observing? In Reports, OTOH, you can successfully change the RecordSource only in the Open event. Larry Linson Microsoft Office Access MVP this is my code in the after update of the cboProcessor strSQL = "SELECT tblMain.* FROM tblMain" & _ " WHERE tblMain.Status='Processed'" & _ " AND tblMain.CashTicket=" & [Forms]![frmEditChecksNew]! [cboTicket] & _ " AND tblMain.Processor='" & [Forms]![frmEditChecksNew]! [cboProcessor] & "'" Me.RecordSource = strSQL Me.Requery the form opens with No recordsource, when the after update of cboProcessor code executes I get the following error Run-Time error '2001' You Canceled the Previous Operation if I then choose debug the me.recordsource=strsql is highlighted in yellow bobh. |
#6
| |||
| |||
|
|
bobhwrote: On Mar 6, 12:06 am, "Larry Linson" <boun... (AT) localhost (DOT) not> wrote: IIRC, in a Form, you can change the RecordSource at the Open event or any time thereafter, and you do not have to requery, because changing the RecordSource causes the Form to be Requeried. *It would seem from your question that your experience differs... what are you observing? In Reports, OTOH, you can successfully change the RecordSource only in the Open event. Larry Linson Microsoft Office Access MVP this is my code in the after update of the cboProcessor * *strSQL = "SELECT tblMain.* FROM tblMain" & _ * * * " WHERE tblMain.Status='Processed'" & _ * * * " AND tblMain.CashTicket=" & [Forms]![frmEditChecksNew]! [cboTicket] & _ * * * " AND tblMain.Processor='" & [Forms]![frmEditChecksNew]! [cboProcessor] & "'" * *Me.RecordSource = strSQL * *Me.Requery the form opens with No recordsource, when the after update of cboProcessor code executes I get the following error Run-Time error '2001' You Canceled the Previous Operation if I then choose debug the me.recordsource=strsql is highlighted in yellow bobh. Have you done a * * * * Debug.Print strSQL and then copy/pasted the result into a query?- Hide quoted text - - Show quoted text - |

#7
| |||
| |||
|
|
On Mar 6, 2:08 pm, Salad <o... (AT) vinegar (DOT) com> wrote: bobhwrote: On Mar 6, 12:06 am, "Larry Linson" <boun... (AT) localhost (DOT) not> wrote: IIRC, in a Form, you can change the RecordSource at the Open event or any time thereafter, and you do not have to requery, because changing the RecordSource causes the Form to be Requeried. It would seem from your question that your experience differs... what are you observing? In Reports, OTOH, you can successfully change the RecordSource only in the Open event. Larry Linson Microsoft Office Access MVP this is my code in the after update of the cboProcessor strSQL = "SELECT tblMain.* FROM tblMain" & _ " WHERE tblMain.Status='Processed'" & _ " AND tblMain.CashTicket=" & [Forms]![frmEditChecksNew]! [cboTicket] & _ " AND tblMain.Processor='" & [Forms]![frmEditChecksNew]! [cboProcessor] & "'" Me.RecordSource = strSQL Me.Requery the form opens with No recordsource, when the after update of cboProcessor code executes I get the following error Run-Time error '2001' You Canceled the Previous Operation if I then choose debug the me.recordsource=strsql is highlighted in yellow bobh. Have you done a Debug.Print strSQL and then copy/pasted the result into a query?- Hide quoted text - - Show quoted text - Oooops! just did, didn't have tick marks around CaskTicket(it's a text value)......... all is well again ![]() thanks bobh. |
#8
| |||
| |||
|
|
bobhwrote: On Mar 6, 2:08 pm, Salad <o... (AT) vinegar (DOT) com> wrote: bobhwrote: On Mar 6, 12:06 am, "Larry Linson" <boun... (AT) localhost (DOT) not> wrote: IIRC, in a Form, you can change the RecordSource at the Open event or any time thereafter, and you do not have to requery, because changing the RecordSource causes the Form to be Requeried. *It would seem from your question that your experience differs... what are you observing? In Reports, OTOH, you can successfully change the RecordSource only inthe Open event. Larry Linson Microsoft Office Access MVP this is my code in the after update of the cboProcessor * strSQL = "SELECT tblMain.* FROM tblMain" & _ * * *" WHERE tblMain.Status='Processed'" & _ * * *" AND tblMain.CashTicket=" & [Forms]![frmEditChecksNew]! [cboTicket] & _ * * *" AND tblMain.Processor='" & [Forms]![frmEditChecksNew]! [cboProcessor] & "'" * Me.RecordSource = strSQL * Me.Requery the form opens with No recordsource, when the after update of cboProcessor code executes I get the following error Run-Time error '2001' You Canceled the Previous Operation if I then choose debug the me.recordsource=strsql is highlighted in yellow bobh. Have you done a * * * *Debug.Print strSQL and then copy/pasted the result into a query?- Hide quoted text - - Show quoted text - Oooops! just did, * didn't have tick marks around CaskTicket(it's a text value)......... *all is well again * ![]() thanks bobh. Not a prob. *I was wondering how you present a form with no record source. *When I do so, I get a bunch of #Names.- Hide quoted text - - Show quoted text - |
![]() |
| Thread Tools | |
| Display Modes | |
| |