473,799 Members | 3,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1897
Br
piet <pi******@pando ra.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 [WrittenToHistor y]"
Case 3:
SQLWhere = ""
Case 4:
SQLWhere = " WHERE [EndDate] >= #" & Format(DateAdd( "d", -1,
Date), "mm/d/yyyy") & "# OR NOT [WrittenToHistor y]"
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_exi t:
Exit Sub
ApplyFilter_err :
MsgBox Err.Description , 48, "Error in ApplyFilter()"
Resume ApplyFilter_exi t
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
3850
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. The forms match with the tables: Client main, Intake, Financial, Fees, Payments, Bills, Bill Line Items. The design works thusly - Client Main relates to Intake. Intake relates to financial. Financial relates Fees, Payments and Bills. Bills relates to Bill Line Items. On the form, I use the...
2
1618
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 adds a new record to the subform, the form saves the record on the table, now if, for example, user decides to change the JobNumber, there is a query that runs to delete the old jobnumber and related data from the table. But the problem is, when It deletes the records, "Deleted" appears in all...
4
7022
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 subform is bound to. The requery is done when the user enters the last qualifying field on the main form. In one case this works fine, the subform shows the data the user wants to update -- which means showing all the data put in previously (ie showing this via the requery and the continuous...
6
2088
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 - Department, Surname and Forename. The user chooses the department they want and then the corresponding surnames from that department can be chosen from the Surname box and then the Forename depending on which Surname they chose. I then have a command button which produces the results of the...
9
9716
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 Field: TrainingMasterSK The second subform has a master-child link to the first subform. subform2 - Master Field: subTrainingModule.Form!TrainingModuleTopicSK Child Field: TrainingModuleTopicSK
11
7178
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 initially cracked up to be. In the back of my mind I am wonder if this is causing my problem, but I don’t want to go through the work to convert to DAO unless I know it is truly in my best interest.) I am having problems getting a requery to show up consistently on a couple of forms. I have...
2
1014
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 (FormB) modally which is used to input and save a new record to the table on which the recordset is based. On closing FormB after inputting a new record, I would like to refresh/requery the listing in FormA automatically so that it includes the new record. I don't seem to be able to get this to...
2
1774
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 this form is to record payments by 'source' (batches) so frmMain's source is a query on BatchPaymentID. New 'source' for payment, new BatchPaymentID. 1st subform (sfrmOne) is a client list of just the client's that would have that source of payment. Next subform (sfrmTwo) is a list of charges...
4
3433
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, “tblProjects” containing names of the office projects, and “tblStatusReports” containing the “StafferID” (link to Staffer table), the “ProjectID” (link to Projects table), a “Date” field, and a “Notes” field. There is a main form, “frmStaffEntry,” with a subform, “frmStatusReports,” for a user to...
14
4588
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 tested) under Vista. A workaround was suggested by another group member at that time, but it's hardly ideal. MS should really look at this and fix it. When a form containing a chart is opened the chart object is visible, but no chart data is visible. If any other form is opened over the top...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.