472,353 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Problem on requery a form

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
1 1806
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Diana Gard | last post by:
Perhaps this is a design flaw, please let me know. I'm using Access 2000. I have a form with a tab control and 5 subforms within those tabs. ...
2
by: Bob | last post by:
I have a form, and a subform based on a query. I want to delete specific records from my table based on certain conditions. I mean, when the user...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the...
6
by: visionstate | last post by:
Hi there, I am building a database that requires cascading lists on a form. I currently have (I may be adding more later) 3 combo boxes on my form...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child...
11
by: mrowe | last post by:
I am using Access 2003. (I am also using ADO in the vast majority of my code. I recently read a post that indicated that ADO is not all that is was...
2
by: Lyn | last post by:
Hi, I am using a form (FormA) to list the records in a recordset. In the FormA footer, I have an "Add" command button that opens a new form...
2
by: Ron | last post by:
Hi All, I've got a main form (frmMain) with 5 subforms on it. All subforms are linked to different hidden controls on frmMain. The purpose of...
4
by: JHite | last post by:
I am using Access 2003 on Windows XP. This is a simple database that contains “tblStaffers” containing names of the office staffers,...
14
by: Wayne | last post by:
I posted about this problem over 12 months ago and even after Vista SP1 the problem still exists when running an Access database (A2003 and A2007...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.