Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft Access > Re: Can't chang...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 7 Topic 30153 of 31273
Post > Topic >>

Re: Can't change a form's data source.....why?

by Bruce <deluxeinformation@[EMAIL PROTECTED] > May 2, 2008 at 12:39 PM

On May 2, 1:55 pm, RLN <nospam...@[EMAIL PROTECTED]
> wrote:
> I have an option group control with 2 choices:
> Sort ASC and Sort DESC
> When this choice is made, I want to change the recordsource for the
> current form and do a refresh so it sorts that data in the order
> specified by the option group.
>
> When it gets to the line Me.Recordsource" it errors out with "Object
> cannot sup****t this property or method."
>
> I've already tried:
> Forms!frmMyformName.setfocus (prior to changing the recordsource)  as
> well as:
> Forms!frmMyformName.recordsource = "Select * from..." and that does not
> work either."
>
> When I am in a subroutine for ControlX that exists on FormX, what is the
> proper syntax for changing FormX's  recordsource and doing a refresh of
> the form while  ControlX inside that form has the focus?
>
> (here's the code so far)
>
> Private Sub optSortMethod2_Click()
> On Error GoTo Err1
> Dim strSortBy As String
> Dim strSelect As String
> cmbSort.SetFocus
> strSortBy = "order by " & cmbSort.Text
> Select Case optSortMethod2.Value
>    Case 1
>        strSortBy = strSortBy & " Asc"
>    Case 2
>        strSortBy = strSortBy & " Desc"
>    Case Else
>       'do nothing here
> End Select
>
> Me.RecordSource = "Select * from tblMyTable where DATEREC BETWEEN #" &
> lblFromDate & "# AND #" & lblToDate & "#" & strSortBy
>
> '  Forms!frmHistory.SetFocus
> '  Forms!frmHistory.RecordSource = "Select * from tblMyTable where
> DATEREC BETWEEN #" & lblFromDate & "# AND #" & lblToDate & "#" &
> strSortBy
> '  Me.Refresh
>
> Exit1:
>   Exit Sub
> Err1:
>     MsgBox Err.Number & "-" & Err.DESCRIPTION, vbOKOnly, gblPgmTitle &
> gblPgmErrorTag & "-optSortMethod2_Click()"
>    Resume Exit1
>
> End Sub
>
> *** Sent via Developersdexhttp://www.developersdex.com***

The problem, I believe, is the references to lblFromDate and
lblToDate.  If these are label controls, you will get this error.  To
refer to the text displayed in the label controls, use their caption
properties, i.e.

Forms!frmHistory.RecordSource = "Select * from tblMyTable where
DATEREC BETWEEN #" & lblFromDate.Caption & "# AND #" &
lblToDate.Caption & "#" & strSortBy

Bruce
 




 7 Posts in Topic:
Can't change a form's data source.....why?
RLN <nospamrln@[EMAIL   2008-05-02 13:55:41 
Re: Can't change a form's data source.....why?
Rich P <rpng123@[EMAIL  2008-05-02 14:30:46 
Re: Can't change a form's data source.....why?
Bruce <deluxeinformati  2008-05-02 12:39:22 
Re: Can't change a form's data source.....why?
RLN <nospamrln@[EMAIL   2008-05-09 11:02:40 
Re: Can't change a form's data source.....why?
Salad <oil@[EMAIL PROT  2008-05-02 14:48:34 
Re: Can't change a form's data source.....why?
Bob Quintal <rquintal@  2008-05-02 18:07:35 
Re: Can't change a form's data source.....why?
RLN <nospamrln@[EMAIL   2008-05-09 11:06:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 6 16:10:09 CDT 2008.