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 > Can't change a ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 30153 of 30680
Post > Topic >>

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

by RLN <nospamrln@[EMAIL PROTECTED] > May 2, 2008 at 01:55 PM

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 Developersdex http://www.developersdex.com
***
 




 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
tan13V112 Wed Jul 9 0:51:30 CDT 2008.