473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Macros in forms based on different tables - a syntax question

Walt in Decatur
I'm an amateur at databases, so forgive this rookie question.

I am developing a database to capture building planning information

I have a form that deposits general data about a given space into a table. On that form I have a command button which invokes a macro that filters the records based on a particular criteria (e.g. only spaces that are laboratories). This works just fine.

I also have another form that deals with the plumbing services for the space. This form deposits data into a different table. The two tables are joined via a field called "Room Name". I have copied the above-mentioned command button to this form as well.

The problem is that I get the "Enter Parameter Value" prompt when I attempt to use the command button. So there may be some syntax or procedure boo-boo I've made in making the reference to the tables.

I've also tried it by basing the second form on a query which takes data from both tables. The command buttons and macros work OK, in this case. But I'm unable to input data. So either way, I'm in deep doo-doo.

Any help would be appreciated.

Here is the applyfilter statement from the macro:

[tbl_general_data].[Super-Category]="Laboratory Space" And [tbl_general_data].[Number of Spaces - Design]<>0

the second form is based on tbl_piped_lab_services_data
Jun 5 '07 #1
7 1390
MMcCarthy
14,534 Expert Mod 8TB
Sorry but this question is very confusing.

Firstly you said you copied a command button from one form to another. Don't do this as it probably won't work.

Try creating your command button using the wizard on the second form and see what happens.
Jun 13 '07 #2
Gee, I thought I was quite clear... :-(
I tried the "use the wizard to create the command button" method - it didn't work.

Again, the basic idea is that the command button calls an event procedure - in this case a macro that applies a filter to the records so only a certain types show up in the form. Macro's "WHERE" statement refers to a table where I have dumped general data. It is there that the field resides which the "WHERE" statement references. As I've said, this all works perfectly on a form which is directly based on this same table. But it won't work when the form is based on another table. Of course, the reason for a slew of tables is that I wanted to "normalize" the relational database.

Could a dLookUp function provide a work-around? Is this a syntax error or a coding issue? Would it work it if these were a form and a subform? I don't know, as I've said, I have no formal training in any of this.

Any and all hints or suggestions will be appreciated. Extensive web search has not yet turned up an idea of what might not be working.

Sorry but this question is very confusing.

Firstly you said you copied a command button from one form to another. Don't do this as it probably won't work.

Try creating your command button using the wizard on the second form and see what happens.
Jun 13 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
I understand what a filter is what I don't know is what exactly your filter is working on. Can you give the exact SQL statement that the form being filtered is based on. Without more information the best guess I can make is that you are filtering a query that is already filtered.

e.g. If your form was based on a query like

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT EmpID, EmpName, DeptID, JoinDate 
  3. FROM Employees
  4. WHERE JoinDate > #01/01/07#
  5.  
Then if you tried to add a filter

WHERE DeptID = 23

You would now have an invalid sql statement with two where statements. The filter should be:

AND DeptID = 23

For the moment this is guesswork as I don't know what your current sql query is.

Mary
Jun 13 '07 #4
Mary:

Thanks for helping, that's very kind of you. Please bear with me just a little bit longer.

I've actually tried to solve this problem differently. I've based the send form on a query that combines fields from two different tables (see SQL for this query below). Now my filters work, but I'm unable to enter any data - which is the purpose of the form. I don't know what I need to change about the way the form or the underlying query is structured to allow data input.

Here is the query SQL:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT tbl_general_data.[Room Name], tbl_general_data.Department, tbl_general_data.[Functional Unit], tbl_general_data.[Space Type], tbl_general_data.[Design Area], tbl_general_data.[Number of People], tbl_general_data.[Number of Spaces - Design], tbl_general_data.[Super-Category], tbl_general_data.[Space Category], tbl_AV_data.[Projection Screens], tbl_AV_data.[Projection Screens Number], tbl_AV_data.[Projection Screens Type], tbl_AV_data.Projectors, tbl_AV_data.[Projectors Number], tbl_AV_data.[Projectors Mounting], tbl_AV_data.[Video Cameras], tbl_AV_data.[Video Cameras Number], tbl_AV_data.[Camera 1 Mounting], tbl_AV_data.[Camera 2 Mounting], tbl_AV_data.[Camera 3 Mounting], tbl_AV_data.[Camera 4 Mounting], tbl_AV_data.[TV Monitors], tbl_AV_data.[TV Monitors Number], tbl_AV_data.[Writing Surfaces], tbl_AV_data.[Writing Surfaces Type], tbl_AV_data.[Interactive Whiteboards], tbl_AV_data.Microphones, tbl_AV_data.[Microphones Number], tbl_AV_data.Speakers, tbl_AV_data.[Speakers Number], tbl_AV_data.[Speakers Mounting], tbl_AV_data.[Audience Participation System]
  3. FROM tbl_general_data INNER JOIN tbl_AV_data ON tbl_general_data.[Room Name] = tbl_AV_data.[Room Name];
  4.  
Walter
Jun 13 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Hi Walter,

At a Guess I'd say your query's not updateable. Try this instead ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT tbl_general_data.*, tbl_AV_data.* 
  3. FROM tbl_general_data INNER JOIN tbl_AV_data 
  4. ON tbl_general_data.[Room Name] = tbl_AV_data.[Room Name];
  5.  
This assumes there is only a one to one relationship between theses two tables. If there is a one to many relationship you can't have this as the query of the form. You will need to look at subforms.
Jun 13 '07 #6
I have solved the problem by structuring the forms the way I think they ought to have been in the first place, that is to have all of the secondary forms relating to inputing data for a given space become subforms of the main form. I just took the forms I had already made, did some graphical reformatting, and made each of them as the source of the subform object on the main form. The command buttons that filter the records now only need to exist on the main form and work just as they did before. Because the main form and subforms are linked via the [Room Name] field in a one-to-one relationship, the main form and subforms are properly synchronized, and since each subform is only tied to a single table (all of the tables in question are in a proper relational relationship already), I can update the data.

All the answers I received were helpful to get me to think the problem through better. Your patience with me is much appreciated.

Walter

Hi Walter,

At a Guess I'd say your query's not updateable. Try this instead ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT tbl_general_data.*, tbl_AV_data.* 
  3. FROM tbl_general_data INNER JOIN tbl_AV_data 
  4. ON tbl_general_data.[Room Name] = tbl_AV_data.[Room Name];
  5.  
This assumes there is only a one to one relationship between theses two tables. If there is a one to many relationship you can't have this as the query of the form. You will need to look at subforms.
Jun 15 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
You're welcome Walter.

Glad you got it working.

Mary
Jun 15 '07 #8

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

Similar topics

21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
37
by: michele.simionato | last post by:
Paul Rubin wrote: > How about macros? Some pretty horrible things have been done in C > programs with the C preprocessor. But there's a movememnt afloat to > add hygienic macros to Python. Got any...
0
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET...
8
by: SBC News Groups | last post by:
Can someone please tell/show me how I would do the following... I have a table called tblOne. In tblOne I have three fields, two, three, four. I have a form called frmMain. I have three blank...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
0
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...

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.