B
BruceM
I posted a question related to this topic several days ago, to which Duane
Hookom responded. Since several days has elapsed I am starting a new
thread.
I have a database for tracking vendor information. I misdesigned elements
of the database several years ago, but now that I have learned some more I
am trying to correct the design. Each vendor listed as Approved (a Yes/No
field) needs a certificate. Some have more than one. In the original
design Cert1 and Cert2 were fields in the main table. There was no Cert3,
but there needs to be. There was more information about Cert1 (the main
cert) than Cert 2. For instance DateReturned is a field for Cert1, but not
for Cert2; same for the Yes/No field CertificateRequested.
Now I have a new related Certs table. Duane Hookum suggested I use a union
query as the source for an append query which would be used to populate the
related table. Based on his response to my question (and with very little
assistance from Help) I came up with the following:
SELECT VendorID, CertificateType as CertType, ExpirationDate as CertExp,
DateReturned, CertificateRequested as CertRequested
FROM tblVendor
WHERE Approved = True
UNION ALL
SELECT VendorID, Cert2 as CertType, Cert2Date as CertExp
FROM tblVendor
WHERE Approved = True;
DateReturned is the same field name in both the current table and the new
related table; the other fields have different names. Note that these are
not the actual field names, but rather simplified versions for purposes of
this inquiry.
When I attempt to run the query, I receive this error message:
"The number of columns in the two selected tables or queries of a union
query do not match."
I expect this is because the second SELECT contains fewer fields, but I
don't know what to do about that.
Hookom responded. Since several days has elapsed I am starting a new
thread.
I have a database for tracking vendor information. I misdesigned elements
of the database several years ago, but now that I have learned some more I
am trying to correct the design. Each vendor listed as Approved (a Yes/No
field) needs a certificate. Some have more than one. In the original
design Cert1 and Cert2 were fields in the main table. There was no Cert3,
but there needs to be. There was more information about Cert1 (the main
cert) than Cert 2. For instance DateReturned is a field for Cert1, but not
for Cert2; same for the Yes/No field CertificateRequested.
Now I have a new related Certs table. Duane Hookum suggested I use a union
query as the source for an append query which would be used to populate the
related table. Based on his response to my question (and with very little
assistance from Help) I came up with the following:
SELECT VendorID, CertificateType as CertType, ExpirationDate as CertExp,
DateReturned, CertificateRequested as CertRequested
FROM tblVendor
WHERE Approved = True
UNION ALL
SELECT VendorID, Cert2 as CertType, Cert2Date as CertExp
FROM tblVendor
WHERE Approved = True;
DateReturned is the same field name in both the current table and the new
related table; the other fields have different names. Note that these are
not the actual field names, but rather simplified versions for purposes of
this inquiry.
When I attempt to run the query, I receive this error message:
"The number of columns in the two selected tables or queries of a union
query do not match."
I expect this is because the second SELECT contains fewer fields, but I
don't know what to do about that.