How to update form fields based on combo-box value change

S

SWE

Hi,
I have a form which is based on a complicated query.
I'm using MS Access 2003 and I am try to update the fields of the form
according to a combo-box value change.
I have creaded an event handler using VBA for the (After-update) event that
requery the form as follows:

Private Sub RequestStatusID_AfterUpdate()
Me.RecordSource = (Original query) & "where
CoreStudiesRequestStatus.RequestTestStatusID=" & Me.RequestStatusID "
Me.Requery
End Sub

Note: (Me.RequestStatusID) is the mentioned combo-box

any solution please ?

Regards

SWE
 
M

mezzanine1974

I am not good in SQL codes. So i perefer grids most of time.

As data source for your Form, define your complex query by gridview.
In your query, define criteria for column "RequestTestStatusID" as
"Form.RequestStatusID". Close gridview (click yes to save before exit)

And remove RecordSource part from your codes as below.

Private Sub RequestStatusID_AfterUpdate()
Me.Requery
End Sub

It must run.
 
S

SimonG via AccessMonster.com

Not sure how complex your original query is, but you could try using a filter,
something like:

Private Sub RequestStatusID_AfterUpdate()
Dim strFilter As String
strFilter = "CoreStudiesRequestStatus.RequestTestStatusID = " & Me.
RequestStatusID
Me.Filter = strFilter
Me.FilterOn = True
Me.Requery
End Sub


Other wise working with the code you have,
does "(Original query)" include an end of statement ";" mark(?) or already
have a Where clause?
the code you have pasted misses the ";" from the end (assuming the full text
is a SQL statement.

Hope this helps,
Simon
 

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