Val Function Returns Zero Not Missing

Sep 19, 2006

Hi

Im using the Val() function to return numeric data from stored text strings.

My problem is that the function returns zero where the data are missing (i.e. a space character at the desired position within the text string).

This is very problematic for me, as the numeric data I am pulling out are in themselves response codes, where zero means something very different from missing.

Is there a way I can use this or another function to pull out numeric values, but return missing/null where appropriate.

Many thanks

Mat.

View Replies


ADVERTISEMENT

Queries :: GrantID - MAX Function Returns Incorrect Value

Dec 16, 2014

I'm working on a database to track our program's performance under different grants. Services performed for each grant would be entered on a quarterly basis. I am tracking the number completed for each service during the quarterly period.

I want to create a report that shows progress against benchmarks depending on the most recent quarter completed. Rather than fooling with dates, I put a field in the table where the data is entered for the number of the quarter in which the service was performed. The field, 'Quarter', holds numerical values 1-4 corresponding with the quarter. The table holds entries from different projects, distinguished by the field 'GrantID'.

There will be more than one service entered for each GrantID.

I would like to be able to identify the most recent quarter in which services were performed for each GrantID.

I have tried using the MAX function in a query but it seems to be adding "1" to the highest quarter number in the field for each GrantID. The code is:

SELECT DevEntryQ.GrantID, Max(DevEntryQ.Quarter) AS MaxOfQuarter
FROM DevEntryQ
GROUP BY DevEntryQ.GrantID;

With this query, if the highest quarter number entered in the table for GrantID1 is 3, the query returns "4".

In Excel, I would use an array formula: = {MAX(IF(Table1[GrantID]=GrantID, Table1[Quarter])}.

I want to use the most recent quarter to retrieve that quarter's benchmarks and show the progress toward the benchmark rather than the overall progress toward the goal for that grant and service.

View 2 Replies View Related

Queries :: DCount Function Returns Correct Result But Datatype Is Text

Feb 4, 2015

I am using the dcount function as the example I display below. The problem is that it returns the correct result (i.e. 59) but the data type is text (59 is on the left side) . I need this to be number.

=DCount("[OrderID]", "Orders", "[ShipRegion] = 'CA'")

View 3 Replies View Related

Help With Function/missing Values

Oct 18, 2007

Hello People!

I am trying to create a new variable that will indicate whether a person has a family history of breast cancer (1=yes). The values for the 4 source variables are either the number 1 or are blank/missing ("no" was not captured). Any help here is greatly appreciated.

Option Compare Database
Option Explicit

Public Function fnBrCaFaHx(BrstAny, BrstMth, Brst1Sis, Brst2Sis As Byte) As Byte
' Determine if participant has a family history of breast cancer.
If BrstAny = 1 Or BrstMth = 1 Or Brst1Sis = 1 Or Brst2Sis = 1 Then
BrCaFaHx = 1
Else
Exit Function
End If
End Function

View 9 Replies View Related

Missing Records (and Missing Updates)

Oct 7, 2005

Hi all

This is an ongoing problem I have had for 4 weeks now.

I have made a a system thats acts like a clock In/clock out Out system.

the structure is somthing like this
ID
Username
tblDailyLog
TimeIn
MorningBreakOut
MorningBreakOut
LunchOut
LunchIn
AfternoonOut
AfternoonIn
TimeOut

All fields apart from ID (autonumber) and username (String*255) are Date field (there are a few others like DateOfTimesheet etc but they arnt important here)

When a user arrives in the morning they make a record which they use for the day

They then have a form with a whole bunch of buttons which simply updates the correct field. For example they click the "Sign in for the Day" button and it updates the correct field with the current time.

Everything was going fine until people noticed that every now and again a sign in time dissapeared.

I have hacked myself to death trying to solve this problem but still the updates go Astray.


Now each time a time is updated the process goes somthing like this


1. the user opens their timesheet for the day (the RS is SNAPSHOT and no locks)

2. User Hits a sign in/out button
3. The record source is changed to "" and all buttons hidden (to ensure the record isnt locked and to make sure you dont do two things at once)
3. The table is updated with the new time (using some dynamic SQL)
4. The table is repeatadly checked using a DO loop to make sure the the correct time went in.
5. when the returned time value of the field matches the varaible used to update it, the form is returned to normal and the user carries on his/her merry way (if it never matches the screen should crash but this never happens).
6. A New record is added to another table called "tblbugfixinglog" which records which field was updated and when. This is so that I have two records in two different ways (figured if one went astray I could pull it back off the other)
7. Another new record is added to yet another table called tblSQLRecord, which simply logs all .RUNSQL statements that are executed.


I thought that the two extra tables (and the check that the record had been updated) would help me track down where the records are going missing, but this isnt the case.

Now it appears that some records arnt being added to tblBugFixingLog and to tblSQLRecord either and some of these tables are getting quite a few #ERROR's in them..

None of the tables are related to any other and i've no idea how #ERROR lines are appearing in a table that has 1 function... to recieve new records ... no editing, no viewing, no deleting.

Does anyone have any idea how these updates/inserts can go missing or create #ERRORs.
I've built plenty of Databases in my time and have never come across this.
__________________________________________________ ______________

This is the function I use to add a record to tblBugfixingLog and tblSQLRecord


Private Sub AddBugLog(ByVal TimesheetNumber As Long, ByVal FieldUpdating As String, ByVal NewFieldValue)
Dim TempSQL As String
TempSQL = "INSERT INTO tblBugFixingLog (TimeAndDateOfEntrySERVER,TimeAndDateOfEntryPC,Fie ldUpdated,NewEntry,UserID,TimesheetNumber,Computer AssetNo) VALUES (" & _
"#" & Format(ServerGetTime(Environ$("LOGONSERVER"))) & "#," & _
"#" & Now & "#," & _
"'" & FieldUpdating & "'," & _
"'" & NewFieldValue & "'," & _
"'" & GetNTUser & "'," & _
"'" & TimesheetNumber & "'," & _
"'" & fOSMachineName & "')"
' MsgBox TempSQL
DoCmd.RunSQL "INSERT INTO tblSQLRecord (Username,DateAndTime,Screen,TheSQL) VALUES('" & LoginInfo.sUsername & "','" & CStr(Now) & "','Add Bug Log function','" & CleanData(TempSQL) & "')", False
'CleanData is a function that removes ' and " from the SQL string so i can easily add the SQL string into the table
DoCmd.RunSQL TempSQL, False
End Sub

Public Function CleanData(ByVal DataToClean As String)
Dim TempData As String
Dim i As Integer
TempData = ""
For i = 1 To Len(DataToClean)
Select Case Mid(DataToClean, i, 1)
Case "'"
TempData = TempData & "`"
Case """"
TempData = TempData & "`"
Case Else
TempData = TempData & Mid(DataToClean, i, 1)
End Select
Next i
CleanData = TempData
End Function


__________________________________________________ ____


I have no idea how this can create #ERROR lines in the table when it is just added to and nothing else.

Does anyone have any clue to what may be happening here.

(Oh yeah and no matter how hard I try, I can't replicate the problem.... works for me every time no matter how harse I am to it!)

Please save what little hair I have left and give me some hope

Cheers
Homer

View 1 Replies View Related

Dealing With Returns

Dec 14, 2007

I have a database that has the basic tables of products, accounts and orders.

I need to figure out how to deal with returns.

Do I create a separate table and link that to the orders table for returns?

I haven't made such a large database file so I was curious if anyone had any information on how to lead me in the right direction. Or if there were any examples. (I've looked around but haven't completely figured out the best way to handle this.)


Thanks!

View 4 Replies View Related

Returns Notification

Apr 13, 2005

I need to make a returns notification if people bring back there rentals back late in my database for a rental place like blockbuster. Please any help would be appreicated. Sorry I rushed this post If you need any more information reply

View 5 Replies View Related

Customer Returns

May 17, 2007

Hi, I am new to access and have just started to build our first database. We are an engineering company who sells automotive components. I have set up the database to process customer orders. Some of the products we sell are remanufactured and sold on an exchange basis. So, once a unit has been sold at some point in the future the customers original unit comes back to us to be remanufactured - but this is not the case with all products we sell.

The exchange units are booked in using a tracking number and then given a unique reference number. I want to create a database that enables me to book an order and be able to enter a courier tracking number for the old unit when a return is required. The tracking number is given to us by our couriers. I want my staff to be able to enter the tracking number and the original customer order to then appear, they then need to enter the unique number given to the return unit.

The problem I have with this is that the exchange unit is normally returned weeks after the original order was sent, and that not every product requires an exchange. Is there a simple way of dealing with this?

Any help is much appreciated

Thanks
Rebecca

View 1 Replies View Related

DLookup Returns Null!!

Nov 26, 2007

Hi,

I wrote the code below in a module. The text box that this part of the code is getting its value from has a DLookup in its control source. The problem is that when the DLookup does not match the criteria it looks for, it returns Null. The code tries to assign Null to a variable of type currency and that returns an error. Is there anyway to convert the Null to 0?

What do you suggest?

Returns DLookup value:
Forms![frmHouse]![qryHouse4].Form![txtTotalVO].Text


All the function:
Public Function CalculateDepositPlusVO()
Dim vAgreedPrice As Currency
Dim vtxtTotalVO As Currency
Dim vtxtAgreedPricePlusVO As Currency

Forms![frmHouse]![qryHouse4].Form![AgreedPrice].SetFocus
vAgreedPrice = Forms![frmHouse]![qryHouse4].Form![AgreedPrice].Text
Forms![frmHouse]![qryHouse4].Form![txtTotalVO].SetFocus
vtxtTotalVO = Forms![frmHouse]![qryHouse4].Form![txtTotalVO].Text
vtxtAgreedPricePlusVO = vAgreedPrice + vtxtTotalVO
Forms![frmHouse]![qryHouse4].Form![txtAgreedPricePlusVO].SetFocus
Forms![frmHouse]![qryHouse4].Form![txtAgreedPricePlusVO].Text = vtxtAgreedPricePlusVO
End Function


Any help will be very much appreciated,
B

View 4 Replies View Related

Simple Query Never Returns

Feb 25, 2008

The following query never returns, even though there is an index on the name field in the Patient table:

SELECT p.Name FROM sheet4 AS s INNER JOIN Patient AS p ON p.NAME LIKE s.LASTNAME + ', ' + s.FIRSTNAME + ' %'

View 4 Replies View Related

Query Returns No Records

Aug 30, 2005

Obvious neophyte issue here, sorry...

I have a table, PURCHASE_ITEMS with 3 fields: ID, TYPE, NAME
Another table, ITEM_TYPES with 2 fields: ID, TYPE

TYPE in both tables is a text field and there is a one-to-many relationship between them.

When I run a query on PURCHASE_ITEMS, I can see all 25 records. When I set a criteria for TYPE to one of the types, no records appear, even though there are 5 or 6 of that type.

Can anyone help me with this absurdly simple problem that I can't seem to get my brain around?

View 1 Replies View Related

Query Returns 2 Results Instead Of 1

Nov 26, 2006

I am creating a database for a hyperthetical car hire company. A customer hires a car from and until a certain date. If a new customer decides to hire a car i want to generate a list of cars that he can choose on depending on the other dates from which other cars are hire from and until. I have created a query that generates all of the cars that the new customer can not use.
I have also generated a list of all of the cars, in the database.

I have created a new query takes the numberplates of all the cars and subtracts the numberplates of the cars that are being used.

This is where i hit a problem. For some reason the query is generating the list of number plates twice and then subtracting the numberplates that are being used. This leaves me with with 2 values for every numberplate that can be used and 1value for every numberplate that cannot be used. Can you help me?

Please post your email address so i can send you the zip file as the file is too large to upload. The query that i am having problems with has the title:SEARCH FOR AVAILIABLE CARS.

Thank You

View 2 Replies View Related

Error When SQL Returns NULL Value

Nov 30, 2006

Hi,

I have a webpage which shows some results upon executing some SQL statements. However, i will met with some problems when the SQL statements return a NULL value therefore i would like to do some error checking such that when the SQL statement returns NULL, i will direct the user to another page.

Is it possible for me to try sth such as:

if strSQL = SELECT .. FROM .. WHERE .. = NULL then
response redirect ...

Was wondering if anybody would be able to give me some advise.

Thank you.

View 1 Replies View Related

Query Returns No Results

Feb 7, 2007

Hi all,

I think this could be another one of my stupid moments. Here is my query expression -


IIf([WHAT TEAM?]=1,[strCurrent_Team]="FINANCE",[strCurrent_Team]<>"FINANCE")


When run, the user is prompted to enter a team number. If they enter 1, then by my reckoning the query should return all records where [strCurrent_Team] = "Finance".

However, no records are returned.

strCurrent_Team is formatted as text.

Can anyone tell me what I am doing wrong here?

Cheers,

Rob

View 3 Replies View Related

When Query Returns No Records In Set

Jul 29, 2007

I hope this doesn't sound too simple for this forum, I'm only a newbie!
I have a select query that will display the recordset that meets the criteria (OK I know that's not a big deal) but...I want to know if, when there are no records that meet the criteria, can I open a form (dialog box maybe) that will say there are no records found instead of showing a blank recordset. Once again I hope this is not so blindingly obvious that I have to start watching my coffee intake

Thanks in advance

View 2 Replies View Related

Query Returns Every Possible Combination

Mar 5, 2008

Hi, i'm hoping someone here might be able to help me. I have come to a bit of a dead end with a database application i am working on.

The database is a delivery newspaper management system for a newsagents. Basically i need it to link customers to the paper they wish to receive, organise them into delivery rounds, and produce a bill for each customer based on the newspaper they get delivered.

The problem I am currently having is when it comes to the billing.
I have:
a table that stores customer details
a table that stores newspaper details (inc. price)
a table that stores the customerID and then the NewspaperID for each day of the week. (since not all customers get a paper everyday of the week)

If a customer gets two papers then two entries are made in the requirements table under there CustomerID)

Now to fetch the price of the newspaper the customer is down to receive each day and then add these all together is where i have been having trouble.

After many different attempts the solution i am currently using is this. I have a query for each day of the week. Each query take the customerID from the requirements table, then the newspaper price from the table storing newspaper details.
The problem here is that the query returns the CustomerID next to every newspaper in the database. I found the solution was this. I added the newspaperId from the newspaper details table and in the criteria stated "[tableRequirements].[NewspaperID]" And this worked perfectly.
Untill i added a customer who gets two papers. As far as i can tell the query is returning all the possible combinations of which newspaper the customer should get.

Any help with this would be greatly appreciated - thanks in advance.

View 1 Replies View Related

Crosstab Query Max X Returns

Nov 3, 2011

I am trying to find an Access solution to handling the MAX 2/3rds (I.E. 2from3 or 8from12 etc) returns from a series of "Scores" of a league table which will have many players, playing in many matches. I have created a crosstab query which delivers the total scores for each player from each game and played around with a make table query and a report output which I have used in excel to deliver the best 2/3rds of the scores. As others will be using the completed data base I would like to keep the solution within Access but I cannot work out how or if this is possible. Below is a limited output from the crosstab query showing the Total of all games played which I wish to turn into best 2/3rds.

View 5 Replies View Related

Address Lines And Carriage Returns

Aug 11, 2007

I want my query to output an address in one field with carriage returns, where the address lines in the source table are held in individual fields.

So I try...

SELECT [Address1] & Chr$(13) & [Address2] & Chr$(13) & [Address3] etc..

This does not work.

However, if I use a text box on a form, with "New Line in Field" set, and then in code use Sendkeys to post the address and the carriage returns as above, it does work.

Can this be done simply in a query? If so how?

View 1 Replies View Related

Query Returns Unwanted Results: Please Help

Apr 9, 2007

Hi,

I'm trying to create a database project for college and have run into a problem with a query. I am trying to find all bookings that have taken place in the last month, but with added details from other tables.

I have taken the job details and date (with validation for the last month only) from my Jobs table, and this works perfectly. However, when i try to match customer IDs to their names (stored in a seperate table), Access returns the same job multiple times with every customer name possible.

Any help you can give me to return just the one result needed would be greatly appreciated.

Mompo

View 8 Replies View Related

Inner Join Returns Duplicate Entries?

Aug 29, 2007

I'm using a pretty simple inner join on two tables but the some of the same results are showing up twice. If I just remove the inner join all the results are uniquely present. For some reason the inner join creates about 10% more records that are all duplicate entries. Any idea what might cause this? :confused:SELECT products.product_nameFROM products INNER JOIN categories ON products.category = categories.category_nameWHERE ((products.X)=True);

View 2 Replies View Related

Query Returns WRONG FIELD!!!

Nov 9, 2007

This is at least the 3rd time I've come across something that is, to me, an extremely serious bug in Access. Anyone else seen this, and anything I can do to avoid it??
In a query, I ask for the values from Field A.
The query returns the values from Field B, but still calls it Field A.

This is in a fairly complex query. If I delete one particular field from the query, the bug disappears. If I put that field back, the bug returns.

Here is my current query:
SELECT ByPN_1.PartNumber, ByPN_1.LostPerSetup, ByPN_1.ActualMachine, ByPN_1.PermQty, ByPN_1.FirstOfFeederSize, ByPN_1.Leaf1, ByPN_1.FirstOfType, ByPN_1.NonPerm, IIf([nonperm]*[concurrentsetups]<1,1,CLng([nonperm]*[concurrentsetups])) AS QtyIfDed, [nonperm]*[setupsperday] AS MaxLoadsSavedPerDay, [qtyifded]*[setupsperday]/[concurrentsetups] AS DedLoadsSavedPerDay, IIf([maxloadssavedperday]<[dedloadssavedperday],[maxloadssavedperday],[dedloadssavedperday]) AS LoadsSavedPerDay, [loadssavedperday]*[laborrate]*[loadunloadperfeeder]*250/60 AS Labor_Annual, master_attr.STD_COST, [loadssavedperday]*[lostpersetup]*[std_cost]*250 AS Parts_Annual
FROM (ByPN_1 LEFT JOIN FeederCost1 ON (ByPN_1.ActualMachine = FeederCost1.Machine) AND (ByPN_1.FirstOfFeederSize = FeederCost1.Size) AND (ByPN_1.FirstOfType = FeederCost1.Type)) LEFT JOIN master_attr ON ByPN_1.PartNumber = master_attr.ITEM
WHERE (((ByPN_1.PartNumber)=107573));

HEre's the pertinent part of the record from BYPN_1:
PartNumberLostPerSetupFirstOfFeederSize
107573 3 12X4

But here's what the query returns:
PartNumberLostPerSetupFirstOfFeederSize
107573 12X4 12X4

Now, if I just delete the "parts_annual" field from the query:
SELECT ByPN_1.PartNumber, ByPN_1.LostPerSetup, ByPN_1.FirstOfFeederSize, ByPN_1.ActualMachine, ByPN_1.PermQty, ByPN_1.Leaf1, ByPN_1.FirstOfType, ByPN_1.NonPerm, IIf([nonperm]*[concurrentsetups]<1,1,CLng([nonperm]*[concurrentsetups])) AS QtyIfDed, [nonperm]*[setupsperday] AS MaxLoadsSavedPerDay, [qtyifded]*[setupsperday]/[concurrentsetups] AS DedLoadsSavedPerDay, IIf([maxloadssavedperday]<[dedloadssavedperday],[maxloadssavedperday],[dedloadssavedperday]) AS LoadsSavedPerDay, [loadssavedperday]*[laborrate]*[loadunloadperfeeder]*250/60 AS Labor_Annual, master_attr.STD_COST
FROM (ByPN_1 LEFT JOIN FeederCost1 ON (ByPN_1.ActualMachine = FeederCost1.Machine) AND (ByPN_1.FirstOfFeederSize = FeederCost1.Size) AND (ByPN_1.FirstOfType = FeederCost1.Type)) LEFT JOIN master_attr ON ByPN_1.PartNumber = master_attr.ITEM
WHERE (((ByPN_1.PartNumber)=107573));

Now the query returns what I expect:
PartNumberLostPerSetupFirstOfFeederSize
107573 3 12X4

View 14 Replies View Related

Modules & VBA :: DCount Returns 0 For All Departments

Jun 8, 2015

Upgraded from Access 2003 to Access 2010. My DCount query was working fine in Access 2003 for many years but now I am having issues. Everything is written in VBA.

Routine:
1.) Insert records into table tblEmployee
2.) Query table tblEmployee to count how many employees are in each department using DCount.

Issue:
DCount returns 0 for all Departments.

Findings:
If I manually open table tblEmployee and edit an employees department (I actually named it the same department), DCount will then find 1 person in that department (the record I manually edited). It seems a manually edited record will be counted but anything written by the insert query is ignored.

View 14 Replies View Related

Queries :: SQL Like Returns False Records

Jul 9, 2015

SELECT tbl_Visits.vst_VisitDate, tbl_Visits.vst_Complaint, tbl_Visits.vst_Diagnosis
FROM tbl_Visits
WHERE (((tbl_Visits.vst_Complaint) Like "*asthma*")) OR (((tbl_Visits.vst_Diagnosis) Like "*asthma*"));

returns records with no occurrences of asthma. about 4 of 638 hits.

View 14 Replies View Related

Modules & VBA :: RecordSet - Nothing After SQL Query Returns Value

Jun 11, 2014

I'm trying to assign the result of an SQL query to a variable using VBA in Access. The query returns a value but the variable which it is assigned to has a value of Nothing. Here is the code snippet:

Dim queryReturnID As String
queryReturnID = "select dbo_tbl_SupplierReturn.ReturnID from dbo_tbl_SupplierReturn" & _
" where SupplierID = " & lstPOHdr.Column(1)
Debug.Print queryReturnID
Dim RecordSet1 As DAO.RecordSet
Set RecordSet1 = CurrentDb.OpenRecordset(queryReturnID)

View 3 Replies View Related

Queries :: Count Returns Null Instead Of Zero

Sep 12, 2013

I have a count column in this query, and i would like for it to return a zero instead of null if it doesnt find anything to count. Here's the SQL for the query.

Code:
SELECT Documents.Status, Count(Documents.Document) AS CountOfDocument
FROM [Request Details] INNER JOIN Documents ON [Request Details].Request_ID = Documents.Request_ID
GROUP BY Documents.Status, [Request Details].Contract, [Request Details].CDRL, [Request Details].Change_Cycle
HAVING (((Documents.Status)="No Record") AND (([Request Details].Contract)=[Forms]![Report Runner]![Contract]) AND (([Request Details].CDRL)=[Forms]![Report Runner]![CDRL]) AND (([Request Details].Change_Cycle)=[Forms]![Report Runner]![ChangeCycle]));

View 13 Replies View Related

Modules & VBA :: Creating A Function That Counts Records And Use That Function In A Query

Dec 11, 2013

So basically I need making a function that will count the number of records from another table/query based on a field from the current query.

View 2 Replies View Related







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