Changing subform recordset - error generated.

G

Guest

I have a 'Mfrs_Table' subform inside a 'Suppliers_Table' form along with a
textbox containing SQL to build a Mfrs_Table recordset. When I select 'Use
SQL' from a combobox I would like to change the recordset of the 'Mfrs_Table'
subform accordingly.

The Test() function is invoked by the combobox when it changes and
illustrates the basic concept:

Public Function Test()
Dim sSQL_Mfrs As String
Dim oRS_Mfrs As Recordset

sSQL_Mfrs = "SELECT * FROM Mfrs WHERE SupplierID=" & CStr(Me!SupplierID)
Set oRS_Mfrs = goCurrentDB.OpenRecordset(sSQL_Mfrs)
Set Me.Mfrs_Table.Form.Recordset = oRS_Mfrs 'Error here
End Function

The following error is generated when the 'set ...Recordset = ..." is
executed:

The macro or function set to the BeforeUpdate or ValidationRule property for
this field is preventing Microsoft Office Access from saving the data in the
field.

How can I fix this problem?
 
A

Albert D. Kallal

Try:

Public Function Test()

Dim sSQL_Mfrs As String
sSQL_Mfrs = "SELECT * FROM Mfrs WHERE SupplierID = " Me!SupplierID
me.MFrs_Table.Form.RecordSource = sSQL_Mfrs

End Function
 

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