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

Problem on requery a form

P: n/a
I have created a continues form, based on a query. In the header, there are
some comboboxes that gives the user the possibility to make certain
selections. Everytime a selection is made on a combobox, there is a VBA
action: ME.REQUERY. That works very fine: the user sees always the result of
his selection(s). There is also a textbox in the header that shows the
number of records in the form (Therefore I use DCOUNT).
Now I've got two problems, when the query returns no records (because the
user choose a selection of items that aren't in the database):

1. The textbox is not updated (should show 0 records).

2. The combobox where the last selection has been made, becomes empty????

I thought I could interfere with some code after the requery, but that don't
works. Is there any idea how to check if the underlying query returns no
records and do some action before updating the form? I can by example show a
message to the user: "there are no records that match your criteria".

Txs
Piet
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Br
piet <pi******@pandora.be> wrote:
I have created a continues form, based on a query. In the header,
there are some comboboxes that gives the user the possibility to make
certain selections. Everytime a selection is made on a combobox,
there is a VBA action: ME.REQUERY.
There's no reason to requery... just change the forms .recordsource.
That works very fine: the user
sees always the result of his selection(s). There is also a textbox
in the header that shows the number of records in the form (Therefore
I use DCOUNT). Now I've got two problems, when the query returns no
records (because
the user choose a selection of items that aren't in the database):

1. The textbox is not updated (should show 0 records).

2. The combobox where the last selection has been made, becomes
empty????
Is the combobox bound?
I thought I could interfere with some code after the requery, but
that don't works. Is there any idea how to check if the underlying
query returns no records and do some action before updating the form?
I can by example show a message to the user: "there are no records
that match your criteria".
Txs
Piet


I use something like this which is called from each control's
AfterUpdate event.......

Private Sub ApplyFilter()
On Error GoTo ApplyFilter_err
Dim SQLWhere As String, SqlOrderBy As String, MySQL As String
Select Case Me![FilterList]
Case 2:
SQLWhere = " WHERE [EndDate] > #" & Format(DateAdd("d", -1, Date),
"mm/d/yyyy") & "#"
Case 1:
SQLWhere = " WHERE [EndDate] <= #" & Format(DateAdd("d", -1,
Date), "mm/d/yyyy") & "# AND [WrittenToHistory]"
Case 3:
SQLWhere = ""
Case 4:
SQLWhere = " WHERE [EndDate] >= #" & Format(DateAdd("d", -1,
Date), "mm/d/yyyy") & "# OR NOT [WrittenToHistory]"
End Select
Select Case Me![SortOrder]
Case "Date": SqlOrderBy = " ORDER BY [StartDate], [Module
Code], [Class]"
Case "Module Code": SqlOrderBy = " ORDER BY [Module Code],
[StartDate], [Class]"
Case "Module Name": SqlOrderBy = " ORDER BY [Module Name],
[StartDate], [Class]"
End Select
MySQL = "SELECT * FROM qryScheduleScan" & SQLWhere & SqlOrderBy & ";"
Me.RecordSource = MySQL
ApplyFilter_exit:
Exit Sub
ApplyFilter_err:
MsgBox Err.Description, 48, "Error in ApplyFilter()"
Resume ApplyFilter_exit
End Sub
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.