473,624 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access 2003, Union query...or Not

4 New Member
I have two UNRELATED tables...Custom ers and Vehicles...

I need to make a query for when an existing customer (in customers table) needs a loaner car for a vehicle in our inventory (in vehicles table) There is no relationship between the customer or vehicle, so how can I apply this.

I tried the following:

select vehicle.[VIN]
from vehicle
where (((Vehicle.[VIN,C,30]) Like "*" & [Search for] & "*"))
UNION
select customer.[lastn]
where (((Customer.[lastn]) Like "*" & [Enter Customers Last Name] & "*"));

The first "where" prompts the user to enter a partial VIN and successfully returns the correct vehicle when run alone.
The second "where" prompts for which customer to use by entering a partial last name, which returns a single customer when run alone.

I will eventually need their name, address, DL#, which all fields are in the Customer table and understand I need the same number of tables and they must be the same type, to which they are. I just used a few fields to see what I am doing wrong.

So, when I run this, it would show the VIN only...I need to see the customers last name also - this is where I'm lost.

Over all I need one query for a form to list the vehicle info and customer info, which is in the DB, but not related.
Dec 21 '16 #1
7 1180
jforbes
1,107 Recognized Expert Top Contributor
You've done a good job at figuring out what you want to display, but I wouldn't rely on a single query to give you those results. You could get this to work, but it will be clunky and with just a bit off effort you could have an elegant solution.

What I would do...
Create a Datasheet Style Form for your Vehicle Table
Create a Datasheet Style Form for your Customers Table
Create a Single Form with Two unbound fields at the Top:
  1. txtVIN
  2. txtCustomer
Then add both of the recently created Datasheet Style Forms as SubForms, right on top of each other.

The fun part starts by adding code to both AfterUpdate events of txtVIN and txtCustomer. The code should create a string for the Filter clause and apply the Filter to the respective Datasheet SubForm. i.e. When your user enters in a VIN, the txtVin_AfterUpd ate will fire, creating a where clause, and apply it to the Vehicle SubForm:
Expand|Select|Wrap|Line Numbers
  1. Dim sSQL as String
  2. sSQL = "VIN LIKE '*' & Me.txtVin.Value & '*'"
  3. Me.subVehicle.Form.Filter = sSQL 
  4. Me.subVehicle.Form.FilterOn = True
  5. Me.subVehicle.Visible = True
  6. Me.subCustomer.Visible = False
Lastly, show just the subForm related to the data that was searched.

The End result will be a Form where the user picks what they are looking for, by entering in either the VIN or Customer Name. If they enter a VIN, only Vehicle information will be displayed, if they enter a Customer Name, only the Customer information will be displayed.
Dec 21 '16 #2
Dubblosephen
4 New Member
I apologize for not relaying why I need this, the info would overlay a scanned form in a report for a loaner vehicle. Both the customer info and vehicle info would always need to be displayed. By the description, specifically the "OR", I don't think this would work.

I literally just thought of having two reports in one, or a subreport....ca n I have two queries in one report with a subreport? Hopefully this won't open a wormhole...?

Main or report 1 - select customer_stuff from customers;
subreport or report 2 - select VIN from vehicles;

I'm going to try this now, unless you are saying your recommendation will always return both the vehicle and customer and I just misunderstood.
Dec 21 '16 #3
PhilOfWalton
1,430 Recognized Expert Top Contributor
I believe you want a join table similar to this:-
Expand|Select|Wrap|Line Numbers
  1. TblJoinVehicleCustomer
  2. VehicleID         Long    Joint Primary Key
  3. CustomerID        Long    Joint Primary Key
  4. DateLoaned        Date
  5. DateReturned      Date
  6.  
Set appropriate relationships, and you have a record of who borrowed each vehicle and when and correspondingly who each vehicle was loaned to.

Phil
Dec 21 '16 #4
Dubblosephen
4 New Member
I cannot join. This is an existing application that I am linking to the tables via Access. Besides, no join should exist as this is vehicles in inventory that a customer may be temporarily assigned as a loaner. I never know in advance which vehicle a customer would be assigned.

There is no way to have two tables where I can select a record from table 1 (Vehicle) and a record from table 2 (Customer) and have the appropriate fields and link to the report...I can't imagine this hasn't been requested before.

Long story short, we (I) created a significant number of reports for us including State forms that auto fill using overlays to a scanned form. We literally print and sign deals, no handwriting. changes we requested from the vendor typically are not 100% of our request or use a really poor 10pt terminal font. So not professional looking. Making the reports/forms ourselves we have the flexibility to make them as professionally looking as we want.

With that said, it's not something I can request from the vendor, at least for free anyways. They typically only do things if its for the greater good, not so much a change for one customer, understandably.

((Thinking out loud...))
I will try to do something using make table which can append to a record, first for the vehicle, then the customer. Since its two-ish times a week, I can create the make table, assign record id numbers as the join and then delete the record after its printed. Since we have a signed copy, I do not need historical records. It will always be a 1 to 1 join with 1 record in each table.
Dec 23 '16 #5
jforbes
1,107 Recognized Expert Top Contributor
Is this for a Form or a Report? Your first post is about a Form, you subsequent posts seem to be about Reports. There are different approaches depending on which target you are going against.
Dec 24 '16 #6
Dubblosephen
4 New Member
I was mistaken, this definitely needs to be a report, not form. At a minimum needs to prompt for a customer and VIN since there is no relationship.
Dec 27 '16 #7
jforbes
1,107 Recognized Expert Top Contributor
If you don't want to build a Table like Phil's TblJoinVehicleC ustomer to link your records together for reporting, then I would create a Form that Launches your Report. The Report Launcher Form would prompt for both the CustomerID and VehicleID and when both are supplied, it would enable the Button that launches the Report. On the Report, I would put two different SubReports, one for the Customer, the other for the Vehicle. The Source for each SubForm would be a Query that refers back to the Launcher Forms CustomerID and VehicleID.

I would not attempt a Union or Join into one Query as that will just complicate things and make maintenance more difficult.
Dec 29 '16 #8

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

Similar topics

0
3949
by: s_gregory | last post by:
The mdb is considerable size 70 +- mb. A complex union query was working well, but when an additional union select... was added into the query, selecting identical fields from a different source, it began to have problems. Failure was observed only in a few PC's at first. For example, in an NT 4.0 SP6 PC, it continued to work OK. But in my Win 2k laptop, it failed. As the union query was gradually simiplified in testing, the failure...
3
6164
by: DFS | last post by:
I've been working around this for years (I believe), so I figured someone here might know: Why won't a crosstab query accept a value from a form reference? TRANSFORM Format(First(QtrAvg),'Fixed') AS FirstQtrAvg SELECT PropertyCode, Survey, Question FROM SurveyData WHERE PropertyCode = Forms.MainForm.Subform.Form.PropertyCode GROUP BY PropertyCode, Survey, Question
1
1869
by: SAKTHIVEL | last post by:
Hi, Im developing applications using Visual Basic and MS-Access 2003. Union query solves my specific problems. But I unable to call this query from visual basic form like other queries. The query follows: select PSCLNo,Fyearid,CompId, "CLNO" as TrType from VwCLothsrNo UNION select PSCLNo,Fyearid,CompId, "PSNO" as TrType from VwPSsrNo; Visual Basic Form Statement:
1
8370
by: dohminator | last post by:
Hello Experts, I have two systems written in Access 2003 that I'm in the process of merging. A user will be given a specific screen depending on his user name. I have a form (let's call it frmPMain) that I'd like to use as a stand-alone filter but I'd also like it to be a subform of another form (frmWMain). My question is this - In SQL Query Builder is there a way that I can reference a field's parent form without an implicit reference...
4
2482
by: rdsandy | last post by:
Hi, I have some code below in VBA for Access 2003 which is on a button called "RentalCrosstabPercTtlQtyMonthLoc_Click". This is a crosstab query which brings up rental items down the side, who rents along the top, the rental month and total number of each item on that month as rows next to the item, something like this: Item TotalQty Month Renter1 Renter2 .... PC 234 Aug-2007 2.33 4.55 ...
1
2164
by: Jorgo | last post by:
In Access 2003 under Windows XP I have made a database for the local Legacy group and they require reports on Widows of various ages. I have their age calculated and shown in form view, however this number is not transfered back to the table. It is shown as 0. As Query requires the age taken from the table I cannot get the Widows List for eg aged between 60 and 75 Is there any way of getting the age displayed in the table so that it...
14
3638
by: bknabl | last post by:
I'm very new to creating union queries. I understand the purpose but not how to properly implement it for my purpose. So far I've created to perfectly fine crosstab queries. One shows input on a date ordered, the other shows the out put on a date completed. I am trying to combine these two charts into one chart. The code I've got so far will only show one date. I am looking to have 2 (4 if you count the break down into the two material types)...
7
2163
by: Zak Cowen | last post by:
I am trying to get an update query to change the password when run. At the moment I have the two fields; - Password - Change_password I want the query to update my table when the user had written in both of the two fields which should overwrite the previous password with the 'change_password' field. Any help would be much appreciated.
1
2066
by: Hom2013 | last post by:
HI, I'm having trouble with my SQL code truncating memo fields in my union query. Here is the code: SELECT Projects. AS Expr1 , Input2012 AS 2012Input , AS Famt , . AS Lamt , .Project_Funding AS F , .Project_Sponsor AS S
0
8685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8633
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8348
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7176
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
6112
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
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2613
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
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
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.