By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,442 Members | 1,316 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,442 IT Pros & Developers. It's quick & easy.

Refresh continuous form when combo box update

P: 67
Hi,

I create form which default type as continuous form. I have put combo box in that form. When user select on dropdown list from combo box, I would like to show only record that meet condition in form.

Here is what I have tried, but I couldn't get what I expect
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboRevision_AfterUpdate()
  2.     Dim strNewRecord As String
  3.     strNewRecord = "SELECT * FROM history_request_expenditure " _
  4.         & " WHERE revision = '" _
  5.         & Me!cmboRevision.Value & "'"
  6.         Me.txtHidden.SetFocus
  7.         Me.RecordSource = strNewRecord
  8.         Me.Refresh
  9. End Sub
Please give me an idea on how to solve this problem.

Best regards,
Sophanna
Mar 14 '14 #1
Share this Question
Share on Google+
6 Replies


Seth Schrock
Expert 2.5K+
P: 2,951
What is the RowSource for your combo box?
Mar 14 '14 #2

P: 67
This is RowSource for my combo box:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT (history_request_expenditure.revision) AS Expr1 FROM history_request_expenditure ORDER BY history_request_expenditure.revision;
Mar 14 '14 #3

Seth Schrock
Expert 2.5K+
P: 2,951
Is the field Revision a Text data type?

You might try replacing line 8 in your OP with Me.Requery.
Mar 14 '14 #4

P: 67
Hi,

I already tried with Me.Requery but it doesn't work.

Revision is double data type. I could see it change on the form(only one row change with the revision that I chose from dropdown list). And it still shows other records with other revision.

In my table, there are alot of record that has the same revision value and I want to show all that records in my form when I choose Revision from dropdown.
Mar 14 '14 #5

Seth Schrock
Expert 2.5K+
P: 2,951
If Revision is a number data type (which Double is a number), then you need to remove the single quotes that you have in your string around the value of the combo box (the ones at the end of lines 4 and 5). Single quotes are only used for text, hash marks for dates, and nothing around numbers. See what that does.
Mar 14 '14 #6

P: 67
Hi,
I already followed what you told me, but it still change only the first record and shows other revision too.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboRevision_AfterUpdate()
  2.     Dim strNewRecord As String
  3.     strNewRecord = "SELECT * FROM history_request_expenditure " _
  4.         & " WHERE revision = " _
  5.         & Me!cboRevision.Value
  6.         Me.txtHidden.SetFocus
  7.         Me.RecordSource = strNewRecord
  8.         Me.Requery
  9. End Sub
Could anybody tell me how to solve this such as do I need to put loop or something else?
Mar 14 '14 #7

Post your reply

Sign in to post your reply or Sign up for a free account.