Requerying

G

Guest

Hi,

I have a form that has option buttons on it. I have code on the form that
determines whether a option button has been pressed and if it has I want to
requery the form.

Here is the code I have so far.

Private Sub Frame8_AfterUpdate()
If Me!Frame8.Value = 1 Then
The_Year = 2005
Else
The_Year = 2006
End If
Me.RecordSource = "SELECT Tbl_Table.Animal, Tbl_Table.Year,
Tbl_Table.Units, Tbl_Table.Retail FROM Tbl_Table WHERE (((Tbl_Table.Year)=" &
The_Year & "));"
Requery
End Sub

When I select a new option I get the error
Run-time error '200'
You canceled the previous operation.
 
G

Guest

You need to specify what you want to requery, in that case try
Me.Requery

The Me stand for the current form where the code is located in
 
G

Guest

Hi Ofer,

Thanks for quick reply. I had Requery in the line immediately after where
error occurred (see original post) so I moved it before the line and put
'Me.' in front - no luck same error. Any other ideas?

Here is current format...

Private Sub Frame8_AfterUpdate()
If Me!Frame8.Value = 1 Then
The_Year = 2005
Else
The_Year = 2006
End If
Me.Requery
Me.RecordSource = "SELECT Tbl_Table.Animal, Tbl_Table.Year,
Tbl_Table.Units, Tbl_Table.Retail FROM Tbl_Table WHERE (((Tbl_Table.Year)=" &
The_Year & "));"
End Sub
 
G

Guest

Try this

Private Sub Frame8_AfterUpdate()
Dim The_Year As Long
If Me.Frame8 = 1 Then
The_Year = 2005
Else
The_Year = 2006
End If

Me.RecordSource = "SELECT Tbl_Table.Animal, Tbl_Table.Year,
Tbl_Table.Units, Tbl_Table.Retail FROM Tbl_Table WHERE (((Tbl_Table.Year)=" &
The_Year & "));"
Me.Requery
End Sub

If you still get the error, put a code break in the first line (Press F9)
when the cursor is located on the first line, then step the code using the F8
key, and tell me in which line the error accur
 
G

Guest

Hi,

Same error same line - 'Me.RecordSource .........'

I can email it to you if you like - it is only 160kb.
 
G

Guest

You can, to
chamudim <@> hotmail <dot> com

change the file extention from mdb to another type or zip it, other wise
hotmail will remove the attachment
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top