Setting A Format In A Field In A Union Query

Jun 21, 2007

Hi everyone,

Please would someone be able to help me?
I have created a union query however, one of the columns, has not picked up the same format as it has in the tables. As in the tables it has this format
'00000'.

Please woud you be able to advise me how I can change the format on one of the 'columns' in my union query. As one column is 'numbers' and the other is 'text'. I need to change the number column so the format is '00000'.

Thank you in advance for your help.

Nats

View Replies


ADVERTISEMENT

Forms :: Error 13 When Setting Rowsource Of Combobox Using Union Query

Jan 18, 2014

I am trying to design an unbound combobox whose rowsource can be dynamically set based on a union query in order to search 1000's of names returning each name that contains a user defined string. The search does not start until the user defined string reaches 3 characters in length.

There are more details in the attachment but basically the vba code I used all saves OK in the vba editor but I get a runtime error 13 type mismatch when the code attempts to utilise the query to populate the rowsource of the combobox.

View 10 Replies View Related

Queries :: Date Format In SQL Union Query

Nov 11, 2014

I have unified three queries , each query has a field "date",

format is dd/mm/yyyy.

The Union select query however, displays this "date" with different format , dd/mmm/yy

How can I fetch same format in the union query ??

View 3 Replies View Related

Yes/No Feilds Display In Numeric Format When In Union Query

Jan 25, 2008

Hi all,

I have looked everywhere for a solution to this and found none. Its an annoying issue which I would like to get around.

Here is what happens.

I have a union query that gathers rows with different criteria together. The query works execept that the yes/no feild which is set to display as "Yes" or "No" is displayes as 0 for No and -1 for Yes.

I understand that the numeric values are the underlying values of yes/no feilds in access, however they are displayed as yes/no in all my queries and reports execept my union query.

I will include the union query here in case.

The following code is a function that I use to build the union query on the fly based on some parameters. If you are asking why I am doing it like this is becasue I need the rows that have a value for the feild schFeilds(0) to be on top of the final results followed by the rows that don't have any values for the above mentioned feild, and I want them sorted. I found this method to be the only one that gives me the result in the order I need.

' ----------------------------------------------------------

Public Function makeMainPanelQry()
On Error GoTo Err_makeMainPanelQry

Dim db As Database
Dim qd_window As QueryDef
Dim qd_nowindow As QueryDef
Dim strSQL As String, sql_window As String, sql_nowindow As String


Set db = CurrentDb
Set qd_window = db.QueryDefs("Q1")
Set qd_nowindow = db.QueryDefs("Q2")

strStatus = cmbStatus.Value
strReboot = cmbARStatus.Value

strFilter = makeHostFilter(strStatus, strReboot)

schFeilds = Split(getRSchechuleFeild(), ",")

sql_window = "SELECT " & pbl_ReleaseTable & ".Hostname, " & pbl_ReleaseTable & ".Status, " & pbl_ReleaseTable & ".Excluded, " & _
pbl_ReleaseTable & ".AutoReboot as Auto, " & HEAT_PROFILE_NODECOM & "." & schFeilds(0) & ", " & _
HEAT_PROFILE_NODECOM & "." & schFeilds(1) & _
", Technician.FirstName as Assigned, 1 as Priority FROM (" & pbl_ReleaseTable & " LEFT JOIN " & HEAT_PROFILE_NODECOM & " ON " & _
pbl_ReleaseTable & ".Hostname = " & HEAT_PROFILE_NODECOM & ".DeviceName) " & _
"LEFT JOIN Technician ON " & pbl_ReleaseTable & ".TechID = Technician.TechID " & _
"WHERE ((" & pbl_ReleaseTable & ".Excluded) = False) " & _
strFilter & "and " & HEAT_PROFILE_NODECOM & "." & schFeilds(0) & " Not Like """" "
'" ORDER BY " & HEAT_PROFILE_NODECOM & "." & schFeilds(0) & ", " & pbl_ReleaseTable & ".Status"

qd_window.sql = sql_window

sql_nowindow = "SELECT " & pbl_ReleaseTable & ".Hostname, " & pbl_ReleaseTable & ".Status, " & pbl_ReleaseTable & ".Excluded, " & _
pbl_ReleaseTable & ".AutoReboot as Auto, " & HEAT_PROFILE_NODECOM & "." & schFeilds(0) & ", " & _
HEAT_PROFILE_NODECOM & "." & schFeilds(1) & _
", Technician.FirstName as Assigned, 2 as Priority FROM (" & pbl_ReleaseTable & " LEFT JOIN " & HEAT_PROFILE_NODECOM & " ON " & _
pbl_ReleaseTable & ".Hostname = " & HEAT_PROFILE_NODECOM & ".DeviceName) " & _
"LEFT JOIN Technician ON " & pbl_ReleaseTable & ".TechID = Technician.TechID " & _
"WHERE ((" & pbl_ReleaseTable & ".Excluded) = False)" & _
strFilter & "and " & HEAT_PROFILE_NODECOM & "." & schFeilds(0) & " Like """" or " & _
HEAT_PROFILE_NODECOM & "." & schFeilds(0) & " is NULL"
'" ORDER BY Priority, " & HEAT_PROFILE_NODECOM & "." & schFeilds(0) & _
'", " & HEAT_PROFILE_NODECOM & ".Status;"

qd_nowindow.sql = sql_nowindow


strSQL = "SELECT * FROM Q1 " & _
"UNION ALL SELECT * FROM Q2 " & _
"order by Priority, " & schFeilds(0)


Set qd_window = Nothing
Set qd_nowindow = Nothing
Set db = Nothing

makeMainPanelQry = strSQL

Exit_makeMainPanelQry:
Exit Function

Err_makeMainPanelQry:
MsgBox Err.Description
Resume Exit_makeMainPanelQry

End Function

' ----------------------------------------------------------

I woudl really appreciate any assitance as its my last hope for a solution.

Thanks and regards
Sep

View 2 Replies View Related

Queries :: UNION / UNION ALL Query Crashed Access

Oct 24, 2013

I'm having a problem with a UNION / UNION ALL query.It seems there is a application crash fault when running the query that MS are aware of and have issued a hot fix. Unfortunately it will take my IT dept some time to check and install the hot fix If they agree to do it at all.

Problem signature:
Problem Event Name: APPCRASH
Application Name: MSACCESS.EXE
Application Version: 12.0.6606.1000

[code]...

View 1 Replies View Related

Hyperlink Field In Union Query

Mar 8, 2006

Hi,
I have a query that I build using VBA based on some user input. One of the fields I pull out is a hyperlink to particular files on our local network, so the user can click the link and open the relevant file. My problem is that if the SELECT statement contains one (or more) UNIONs the hyperlinks no longer work. The query returns all the fields but the hyperlink field is just text of the form "display_text#link_address#".
I am using MS Access 2000. The UNION statements are required so I can search for multiple keywords in various fields within the table.

An example of the SQL query I generate is:
SELECT DocRef, DocTitle, DocAbstract, DocLink, DocAuthor, DocDate FROM TechDocs
WHERE DocType IN ('TechRep', 'Misc')
AND DocAbstract LIKE ('*drug*')
UNION
SELECT DocRef, DocTitle, DocAbstract, DocLink, DocAuthor, DocDate FROM TechDocs
WHERE DocType IN ('TechRep', 'Misc')
AND DocAbstract LIKE ('*release*');

If I do the query a different way (when I am searching for phrases, not keywords) the hyperlinks work fine. As you can imagine this is very frustrating! I have read that Access 2000 has some problems with UNIONs where it has to order the individual SELECT results before the union or something, but I can't work it out. :confused:

Any help is much appreciated.

View 1 Replies View Related

Using VBA To Change The Name Of A Field In A Union Query

Feb 16, 2007

I have a table called LLD Import Table with the following fields in it.

FileNumber, LandDescription, Qtr1, Sec1, Qtr2, Sec2, Qtr3, Sec3, Qtr4, Sec4, Qtr5, Sec5

Data Example:
123456, T43 R2 W5M, S, 6
123457, T43 R1 W5M, SE, 18, SW, 17
123456, T43 R1 W5M, E, 19, E, 30, SW, 29, E, 31, NE, 18

What I have done so far is to create a Union query to create a new record with the file and land description repeating for each row where there is quarter and section data with the following code:

SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec1 AS Section, [LLD Import Table].Qtr1 AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec1) Is Not Null));
UNION
SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec2 AS Section, [LLD Import Table].Qtr2 AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec2) Is Not Null));
UNION
SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec3 AS Section, [LLD Import Table].Qtr3 AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec3) Is Not Null));
UNION
SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec4 AS Section, [LLD Import Table].Qtr4 AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec4) Is Not Null));
UNION
SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec5 AS Section, [LLD Import Table].Qtr5 AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec5) Is Not Null));

To give this result:

FileNumber, LandDescription, Quarter, Section
123456, T 43 R 1 W5M, NE, 18
123456, T 43 R 1 W5M, E, 19
123456, T 43 R 1 W5M, SW, 29
123456, T 43 R 1 W5M, E, 30
123456, T 43 R 1 W5M, E, 31
123456, T 43 R 2 W5M, S, 6
123457, T 43 R 1 W5M, SW, 17
123457, T 43 R 1 W5M, SE, 18

However the number of Quarters and Sections under a file changes, so next time I my table could have fields up to Qtr20 and Sec20 What I’d like to do is to create a function that will automatically change the # behind the field names (to replace the * in the example below) so that I don’t have to rewrite the Union Query each time. I’ve seen some code examples that can change the value, but don’t quite understand them enough to write one.

SELECT [LLD Import Table].[FileNumber], [LLD Import Table].[LandDescription], [LLD Import Table].Sec* AS Section, [LLD Import Table].Qtr* AS Quarter
FROM [LLD Import Table]
WHERE ((([LLD Import Table].Sec*) Is Not Null));

Your help would be GREATLY appreciated!

View 1 Replies View Related

Union Query Truncates Memo Field????

Jan 4, 2005

I created a Union Query for several linked Excel tables. Certain fields in the Excel table exceed 256 characters and Access (rightfully so) assigns these fields as "Memo". I have create a report based upon the Union Query; however, it will truncate the "Memo" fields to 255 (or 256 characters).

As a side note, if I create a report based upon a simple query using only one of the linked tables, it does not truncate the field.

Any suggestions on what maybe causing this truncation issue?

View 2 Replies View Related

Queries :: Hide Field In Union Query?

Dec 11, 2013

Is there a way to hide a field in a union query? I need to keep the field in the SQL statement because I need to order by it. The field is "Rank," but I don't want it showing up.

View 3 Replies View Related

Modules & VBA :: Union Query - Automate Date Field

Mar 18, 2014

The statement below is a snippet from a union query and is repeated 6 times within the SQL Statement for various reasons, I have to manually change this every month, again is there i tiny bit of code I can insert to replace the following so that it automatically runs the previous months data.

WHERE ArrivalDateTime >= 'February 1 2014'

View 5 Replies View Related

Union Query - Create Additional Field / Clear Records

Jul 20, 2006

The code pasted below creates a union query for a set of tables (J000171, J000174, J000178 etc) and stores the results of the query in a table called temp.

The first piece of code queries the ‘status’ field of a table rjobs for those records with a ‘status’ field of “Live”. Another field within this rjobs table, ‘JobID’, happens to be the name of a table where additional information relating to that job record is held eg. J000178 All of the tables selected in the query on rjobs are then included in the union query.

The second piece of code stores this information in a table called temp

I would like to be able to do 2 things with this;

1.add an additional field to the union query which holds the JobID field value from rjobs (or alternatively the table name from which the data originates eg J000178 etc as that is the same as the JobID file din rjobs)

2.create an option to clear the info in the temp table. Currently additional info is appended, so whenever the query is refreshed new data is simply added to old data. I would like to be able to clear that data where possible.

The union query is run from the on click of a command button on a simple form. Perhaps an additional button could be used to clear the records from the table temp.

Any ideas greatly appreciated.

Here is the existing code …

Option Compare Database
Option Explicit


Private Sub Command0_Click()
Dim db As Database
Dim rsRjobs As Recordset
Dim rsRapps As Recordset
Dim LengthofUnionSQL As Long
Dim sql As String
Dim UnionSQL As String
Set db = CurrentDb
Set rsRjobs = db.OpenRecordset("Select * from rjobs where Status = 'Live'", dbOpenSnapshot)
Do While Not rsRjobs.EOF
UnionSQL = UnionSQL & "Select ObjectID, SearchNo, DateSearched, Consultant, from " & rsRjobs!jobID & " Union "
rsRjobs.MoveNext
Loop
'following two lines are to remove the trailing word Union from the string unionsql
LengthofUnionSQL = Len(UnionSQL)
UnionSQL = Mid(UnionSQL, 1, LengthofUnionSQL - 7)
' Now variable Unionsql will hold the value something like
' Select ObjectID, SearchNo, DateSearched, Consultant from J000145
' Union Select ObjectID, SearchNo, DateSearched, Consultant from J000146
' Union Select ObjectID, SearchNo, DateSearched, Consultant from J000147
MsgBox UnionSQL


Set db = CurrentDb
Dim rsUnionquery As Recordset
Dim rstemp As Recordset
Set rstemp = db.OpenRecordset("temp", dbOpenDynaset, dbSeeChanges)
Set rsUnionquery = db.OpenRecordset(UnionSQL)
Do While Not rsUnionquery.EOF
rstemp.AddNew
rstemp!ObjectID = rsUnionquery!ObjectID
rstemp!SearchNo = rsUnionquery!SearchNo
rstemp!DateSearched = rsUnionquery!DateSearched
rstemp!Consultant = rsUnionquery!Consultant
rstemp!jobID = rsUnionquery!jobID

rstemp.Update
rsUnionquery.MoveNext
Loop

End Sub

View 2 Replies View Related

Setting ALL Dates To UK Format

Jun 28, 2006

My problem is, I'm using a form to build up a query using VBA / SQL, and part of the WHERE portion of my SQL statement includes start / end dates. If I then enter dates in the UK format (dd/mm/yyyy), access will, on saving the query, reverse dd and mm if both are 12 or below. I've managed a work-around using Format(strDate, "mm/dd/yyyy") on the strings that store the dates in VBA to convert them to US (mm/dd/yyyy) format before compiling the SQL statement, but I would like to avoid using US dates completely if possible.

my PC regional settings are UK, I have UK dictionary selected within access, what I'm interested to find out is wether there is any way to force access to only use UK format dates, or is this an inherent problem?

thanks in advance for any insights ;)

Bogzla

View 3 Replies View Related

Queries :: Multi-Field Union Query (Joining Questions And Pictures Into One Report)

Apr 5, 2013

I have two tables containing (let's say for simplicity) questions and attachments (pictures). I am trying to perform a union query to join all the questions and pictures into one report, but it won't let me union the attachment because 'the multi-valued field 'TableA.Pictures' cannot be used in a union query'.

I have searched and searched for a solution (and got kind of close) but i still can't get it to work. The best I can do is union everything like below, which gives all the questions as desired, but says #Error in the pictures column:

SELECT TableA.*
FROM TableA
Union
SELECT TableB.*
FROM TableB;

(Note tables A and B have the same structure, several yes/no and open text questions as well as one attachment field. )

View 8 Replies View Related

Setting A Field In A Query From A Report?

Oct 6, 2004

I know its probably a simple one but I am new to access, so...

I have a simple membership database and in it I keep a record of who I am expecting to attend on a particular date. This is achieved through having a seperate field for each meeting on a simple yes/no type.

I would like to be able to print a report from a form for a particular date showing everyone that would be attending. I have a list box that shows all the fields. What I cant do is set the date I want in the query from the report, can anyone help?

thanks

View 2 Replies View Related

Simple Query Question: Setting A Field To A Set Value

Jul 6, 2007

Putting this in the field box in a query:

read or write: "r"

should create a field called read or write with a value of r in each record in the query, shouldn't it?

Why doesn't it, and how can I make it work?

View 2 Replies View Related

Queries :: Setting To Only Show Field In Simple Query Once

Sep 19, 2013

I have a simple query between two tables joined together by common fields. In my first table (Table 1 - tblLocations) I have information about a building i.e. Location Code, address and total sqft. . In my second table (Table 2 - tblAllocatedSpace), this contains details (Location Code, Room ID, SqFt assigned, etc.) of the space allocated in each building. The two tables are joined together when the “Location Code” in both table match.

In my query, I show the location detail from (Table 1 - tblLocations) and related records from (Table 2 - tblAllocatedSpace). My result looks like the following:

Location Code Sqft Address Assigned Sqft
106067 1,000 600 March Rd 10
106067 1,000 600 March Rd 15
106067 1,000 600 March Rd 12
106067 1,000 600 March Rd 20

The location code, Address and Sqft is rebated each time a space is assigned in (Table 2 – tblAllocatedSpace). When a build a report and need to sum the location Sqft, the number is multiplied by the number of related records in (Table 2 – tblAllocatedSpace). In this example by building total space is 4,000 sqft when I only it to show 1,000.

How do I set to only show the location code and sqft once?

View 1 Replies View Related

Format Query Field To Currency

Aug 24, 2007

I have a calculated field in my query that takes the difference between to incomes. I want to format this field to currency. How can this be done?

View 1 Replies View Related

Query Based On Format Of A Field

Feb 6, 2006

All,

I have a Postcode field in my table and I want to be able to check the data to make sure that it is a correct UK postcode.

Is there away that I can find out the format of the data, to be able to run a query against it, or is there a better way of doing it?

I need to account for all types of UK postcodes (A1 2BC, A12 3BC, AB12 3CD, WC2A 3BC). There are also foreign postcodes in this field.

Help appreciated!

View 2 Replies View Related

Formatnumber To Format A Sum Field In Query?

Feb 29, 2008

I have a query that calculates a sum like this:

Sum: [table1]![field1]*[table1]![field2]

I would like result to have 2 decimal places.

I tried to use formatnumber like this:

Formatnumber(Sum: [table1]![field1]*[table1]![field2];2)

But I get syntax error. please help with the correct formula.

View 3 Replies View Related

Forms :: Assign Field With Special Format Based On Date / Time Format

Feb 17, 2014

I wanted to assign the field "Number of magazine" with special format based on date/time format but showing only year and month in the format: "yyyy-mm".

So in property of this field in format I put yyyy-mm and in input mask I type 0000-00;;-

I also created the form based on the table containing above field and I defined format and input mask for corresponding formant in the same way like at the table.

But if I try to type date for example 2014-01 in text box of the form it comes up with the full date 2014-01-01. Why does it do like this? What do I do incorrectly?

View 2 Replies View Related

Format Numbers In Query Text Field?

Nov 10, 2005

I have a field in a query that contains numbers and text (text field). The numbers displayed come from a percent calculation and display with many decimals ie, .99898745987245. Is there a way to eliminate the decimals with code in the query field? For example .99898745987245 to equal 99%? I can’t format the field as a number or percent because it has both text and numbers. HELP!!
Thanks

View 5 Replies View Related

Format Field In Make Table Query

Feb 27, 2007

DB Setup:
Table1: I have a table (Vendor) that has 2 fields (# & Name) with # being an AutoNumber. So only Name is being input via a form. I have formatted the autonumber field as 000;(000).
Table2: A table that is populated via form with invoice info etc and vendor number is added through a drop down combo box (which also has the above format on it)
Table3: Similar to table2, with slightly diff info but still vendor #

Query1: Is a make table that consolidates table 1 & 2 via union on like fields (ie vendor #) This make table also has the format from above in its properties field, although when i open the table it makes (Table4) the vendor field is not formatted as i need it. So 3 appears as 3 not 003.

Query2: takes table4 adds some extra info and exports file (as txt or xls)using outputTo & TransferText macro so that it can be loaded into a Hyperion Essbase system

My problem is that although the field value is formatted as 003 in appearance, when i take it to excel it changes back to 3 when i need it to stay as 003. I would like the make table query to also format the tables field as 000. Is the problem with the autonumber in the orig table or is it simply excel being stubborn when i take it there. If i changed the vendor field to text string in the make table would i still be able to link it back to the orig vendor table to get the names etc (ie number field linked to text field??)
Thanks in advance

View 1 Replies View Related

Queries :: Change Field Format Within A Query

Sep 23, 2013

I'm having a format problem. I have a query (Q1) that, among other things format a date field as YYYYMM (Field1).

I have a second query (Q2) whose data source is Q1.

In Q2 I need to link Q1 to a table but Field1 is being reformatted as text (confirmed by running a make table query).

I want Field1 to be Number format to eliminate a mismatch error.

I know how to change the format of a field in a table using VBA but I cant seem to find a way of changing the format within a query.

View 2 Replies View Related

How To Set Format Of A Field In Make Table Query

Sep 9, 2015

I have numerous databases that I use with make tables in there, these will often contain Currency values that we need to be set as just General Numbers. We can get it to work in the Query but whenever we run the query, the table it makes always shows up as currency.

Is there a way so that the table created will automatically be just General numbers...

View 2 Replies View Related

Format Of Field Produces Error In Query Calculation

Apr 24, 2005

I have a query that add up the numeric values in a value list assinged in a combo box in response to each question, the row source for question 15 for exmaple is as follows:

ROW SOURCE: 0;"I have no idea";5;"I indicated that I wouldn’t have time today";0;"Was mentioned early on and then not offered again";5;"The salesperson said the vehicle wasn’t available"

I then run a query that adds together the responses to 3 questions, including question 15, the field in the query appearing as follows:

LS5: ([q14]+[q15]+[q16])

It was working fine but has stopped working, the fault lies with q15, if I take it out it works again. So I looked at the table as I am sure it must be the way it is set up, why it worked before I don't know and I attach a screen shot of how the field is set up in the table, which is no different to q14 and q16.

Anyone got any ideas?

One last thing is that it makes no difference if the fileds contain a number (including zero) or are blank

View 7 Replies View Related

Format Field Output Of A Complex Expression In Query.

Feb 8, 2006

I have a simple query to calcualte a profit margin on daily sales lines and I use a quick and dirty expression to calculate the margin in the query so I never need to drill it down further than that level (I don't want to go as far as putting the output into a report as it is only for use when double checking lines for errors which get fixed there and then in the database).

So far so good, however the margin output is a bit awkward to read as I can't seem to format it as a simple percentage. The field properties page doesn't like doing anything with the expression and even typing in a format manually has no effect, so I end up with figures like

36.7768595041322
38.6666666666667
15.6448202959831
etc


the expression i use is:

Margin: IIf([dbo_tbl_sales_invoice_lines.price]=0,"",([dbo_tbl_sales_invoice_lines.price]-[net_cost])/[dbo_tbl_sales_invoice_lines.price]*100)

Is there any way to format this output to show only 1-2 decimal places and be in a proper number format so I can sort them in ascending order properly?

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved