Modules & VBA :: DCount Not Finding Records And Returning 0 All The Time

Sep 10, 2013

It is basically a DCount, and it should find records, but returns 0 all the time. My code is:

Code:

Function cntkit(sftd As Date, sftn As String, typid As Integer, specpaint As Boolean) As Integer 'Counts jobs kitted during shift given by sftd and sftn
Dim timeformat As String
timeformat = "#mm/dd/yyyy hh:nn:ss#" 'need this, to convert it to US datetime format
cntkit = DCount("[JOB]", "Archive", "[Type] =" & typid & " And [Autfinish]=False And [SpecPaint] =" & specpaint & " And ([Kit] BETWEEN " & Format(sftstart(sftd, sftn), timeformat) & " AND " & Format(sftstart(sftd, sftn), timeformat) & ")")
End Function

sftstart and sftend are functions which are returning dates. The funcion works fine if I omit the Between part of the criteria. So the problem is in that part.

View Replies


ADVERTISEMENT

Modules & VBA :: DCount Not Finding Records?

Sep 11, 2013

My DCount statement is not finding a record that I know is there.

Code:
Private Sub Transfer_WN_Books_Click()
Dim ST As String
ST = "H"
If DCount("*", "Books", Author = " & Me!AuthorID & " And StatFlag = " & ST & ") > 0 Then
DoCmd.Beep
End If
End Sub

It never beeps!

View 10 Replies View Related

After Finding Records Show Themone At The Time

Mar 5, 2008

Hi All,


I have the following code to run search:
Code:Private Sub Command20_Click() Me.household_id.SetFocus 'Me.Text21.SetFocus 'subj_num = Text21 DoCmd.FindRecord Me.household_id, acEntier, True, acSearchAll, True, acCurrent, TrueEnd Sub
Let's say it found 5 records matching the search criteria.
I like the Access form show me each record every on second. Meaning show me next record every one second.


I have the follwoing code to loop throgh each record but I nned to run after the find code runs and loops throgh the record that have been found:

I have the following code to do the loop through each record but, I need to run it after running the find code and then loops through the records that have been found:

Code:Private Sub Command10_Click()Dim inti As Integer'Loop through record 1 to 20 in form For inti = 1 To 20 DoCmd.OpenForm "DEM_RECH_CHECK_LIST", , , "[household_id]= " & inti Next inti End Sub



I need some help to combine the above codes.

Thanks in advances,

Abrahim

View 9 Replies View Related

Queries :: Finding Records In A Query Where Date / Time Has Been Used?

Aug 15, 2013

I have a database that is used (partially) to enter appointments during a day. In the appointment column I've entered the date and time as dd-mmm-yyy-hh-nn-ss. I'm now trying to search for appointments entered on a specific day through a user input ([Enter Date] in the query criteria) Problem is, this only returns records where the time hasn't been entered and the time shows as 00:00:00.

I've tried CDate which gives me add/mmm/yyy return. if I try to search against that I get nil returns though. As a test I put DATE() in the criteria but it then says that it's an invalid foremat. I've also tried various machinations of "Like" and "Between" without success.

View 5 Replies View Related

DCount In Calculated Text Box Returning NOTHING

Jun 9, 2005

I am trying to use DCount to count the number of record that = 0 for field checklistitem_1 in table 'Data Input'.

I firstly tried =DCount("[ChecklistItem_1]","Data Input","[ChecklistItem_1] = 0") but this returned nothing.

So I tried =DCount("*","Data Input") just to see if I could get something back and still nothing.

I double check the names are correct, dropping the quotation marks different combination of brackets and nothing every time.

Please help me

View 1 Replies View Related

Forms :: Finding Duplicates - DCount Not Providing Expected Results

Mar 8, 2013

I've been working on trying to get this code to work as expected for days. I'm trying to find duplicates (I can't use primary keys or indexes alone to weed out duplicates due to the structure of the tables involved) in a subform as a user enters data. As soon as a project number is added, the code is supposed to count the number of records that contain that particular project number as well as a category number (there can be multiples of the same project numbers as long as their category numbers are different). This is the code I am using in the "Before Update" event of the field in the subform:

Private Sub ProjectID_BeforeUpdate(Cancel As Integer)

Dim strCriteria As String
Dim RecCount As Integer
strCriteria = "([ProjectID] = " & Me.ProjectID & ") AND ([CatID] = " & Me.CatID & ")"
RecCount = DCount("[ProjHrsID]", "tblProjHrs", strCriteria)

[Code] .....

What could I be doing wrong? Nothing about this code seems to work properly - even the Undo and Cancel=True is a problem (I get the "No current record" error).

View 2 Replies View Related

Modules & VBA :: Returning Correct Number Of Records

May 3, 2014

I am having trouble with the below returning the correct number of records, and can't see why.

I have one table, tblDevice, which has 4 columns, ID | DeviceRecNo | ExcludeFromCheck | StockLocationID

ID - Autonumber
DeviceRecNo - Number
ExcludeFromCheck - Number (1 = yes, 0 - No)
StockLocationID - Number

I have the following running as part of some code, but it is not returning the correct number of records, and I cant see why not. I have tried creating this in a query in Access itself, and copy the SQL into VBA and it still doesn't return the correct number records.

I have 4 records in there for testing, all with StockLocationID = 3, all with different DeviceRecNo, and two each of ExcludeFromCheck, 2x0 and 2x1

Code:
Public Function test()
Dim db As dao.Database
Dim rs1 As dao.Recordset
Set db = CurrentDb
Set rs1 = db.OpenRecordset("SELECT DeviceRecNo FROM tblDevice WHERE StockLocationID = 3 AND ExcludeFromCheck = 'No'")
Debug.Print rs1.RecordCount
End Function

View 3 Replies View Related

Modules & VBA :: Search Form Not Returning Records With Blank Fields

Nov 14, 2013

I'm creating a search form to filter out data based on certain inputs. My VBA code looks like:

Code:
Private Sub Command18_Click()
On Error GoTo errorcatch
Me.Filter = "([Experiments.Log] Like ""*" & Me.Text21 & "*"") AND ([Expdate] Like ""*" & Me.Text22 & "*"") AND ([BaseSolution] Like ""*" & Me.Text24 & "*"") AND([AddCom] Like ""*" & Me.Text25 & "*"") AND ([Test] Like ""*" & Me.Text26 & "*"") AND ([Plan] Like ""*" & Me.Text23 & "*"")"

Me.FilterOn = True
Exit Sub
errorcatch:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub

However, the output does not include records where other fields are blank. I have read that I may need to use Is Null but am not sure how to.

View 3 Replies View Related

DCount - Run Time Error 62506

Apr 20, 2005

Good day,

I am tring to use the DCount function but I am receiveing the following error:

Run time error 62506
Data type mismatch in criteria expression

The syntax I used is:

Dim tlcount As Integer

tlcount = DCount("tl", "tblpension", "tl = '" & Forms!frmpension!txtpentl & "'")

'MsgBox "You have filled out " & tlcount & " monitors so far this month.", vbInformation, "Info"


Just wondering if anyone knew how to help me out, the weird thing about it is that it has been working for a few months.

Thanks

Chris

View 2 Replies View Related

Finding Out The Last Time Data Was Updated

Jan 31, 2006

Hi,

I am using this code below to retrieve the last updated time on the tablea.


lbl_DataLastUpdated.Caption = "Data last updated: - " & Format(CurrentDb.TableDefs("ATM_Info").LastUpdated, "dd/mm/yyyy hh:mm")


This works but the problem i have is, when i add an entry via a form or do anything else via a form. This does not get updated?. I check the properties of the table and that isn't either.

When i then modify something manually in the table (go in and change it). It then updates.

Is there something im doing wrong or is there a better way to check the last updated.

Thanks
k0r54

View 3 Replies View Related

Finding A Minimum Time For A Swimming Event

Feb 21, 2006

I am trying to produce a database that will select a swimmers, best time for each event, and will select the overall best time done by any swimmer in the events.

At the moment I am having some trouble with my queries.

When trying to get the query to select a swimmers best time for the events, It will work when selecting min for the time field and including the following fields:
Forename
Surname
Stroke
Distance
Age group
Gender

However I also wish to include the name of the swimming pool the time was done at and the date at which it was achieved. My problem is that when I add these fields into the query, it looks for the swimmers minimum time in the event, on the date, and at the venue and consequently comes up with all the times the swimmer has done, rather than just the best ones.

I would Really appreciated if anyone had any suggestions as to how I can get over this problem

Thanks in advance

Jennifer

View 14 Replies View Related

Modules & VBA :: Move 10 Records At A Time Button

Nov 29, 2013

I'm using a form with next record and previous record buttons that works fine but as the size of the database has grown it's clear I need a faster way to move through records.

My solution was to have an advance 10 records at a time button but I'm having problems when reaching the far sides of the records.

For example: If I'm on record 9 and I press go back 10 button then access tries to go to record 0 (which doesn't exist) and brings up and error. The same happens if I try to advance more than total number of records.

I found a solution to this which was to disable the button when the recordcount was less than 10. This works except now if I'm on say record 14 and want to go back to 4, i press the button, i goes back to record 10, the button is disabled so it can't go back further and i get an error.

View 3 Replies View Related

Forms :: Returning Difference Between Date / Time Values In HH.MM Format

Dec 11, 2013

I want to be able to display the result of a difference between Date/Time values in "HH.MM" format (i.e. yes I want the result in decimals and I don't want Access to round up or down just because it feels like doing it!). I have used the following:

Example 1:

Dim ActualManHours as Long
ActualManHours = (txtEndTime.Value - txtStartTime.Value) * 86400
txtActualManHours.Value = ActualManHours

Example 2:

Dim ActualManHours as Long
ActualManHours = DateDiff("h",txtStartTime.Value, txtEndTime.Value) & "." & Format(DateDiff("n",txtStartTime.value,txtEndTime. value) Mod 60, "00")

Example 3:

Dim StartTime as Double
Dim EndTime as Double
Dim ActualManHours as Long
StartTime = CDbl(txtStartTime.Value)
EndTime = CDbl(txtEndTime.Value)
ActualManHours = EndTime - StartTime
txtActualManHours.Value = ActualManHours

View 7 Replies View Related

Modules & VBA :: Loop In Batches / X Number Of Records At A Time

Jul 4, 2015

I have a form which uses a loop command to output reports as a PDF. The reports take a bit of time to produce and the record set could contain 100-150 records. Any way that you can split the recordset down into batches. Maybe have a button which creates 1-20 and another 21-40 and so on.

View 1 Replies View Related

Modules & VBA :: Reset Autonumber Each Time Delete / Append Records In A Table?

Oct 25, 2013

I need to reset the autonumber each time I delete/append records in a table. Best way?

View 5 Replies View Related

Queries :: DCount Giving Error For All Records

Oct 31, 2013

I am trying to use DCount to count the number of records (speakers) for each session. Not being very savvy with DCount, I copied code that I had working for another instance of needing to count the number of records.

My query has three fields

Query used: Web/PrintReport_qry
Session Id - number
Speaker - string

Code:
SpeakerCount: DCount("*","Web/PrintReport_qry","[Session ID]='" & [Session ID] & "' And [Speaker]<" & [Speaker])+1

My output for SpeakerCount is "#Error"

View 10 Replies View Related

Finding First Records Only

Nov 1, 2006

lots of customers. lots of orders. i need to query for the first order of each customer only. thoughts?

View 1 Replies View Related

Query Not Returning All The Records I Need

Sep 28, 2005

I have 3 tables - Students, which contains all students; Attendance, which contains dates a particular student was absent; and AttendanceCtrl which contains Quarter beginning/ending dates. I need to be able to calculate the number of days a student was present, absent, tardy in a quarter. The query needs to extract all students regardless of whether or not they missed any days. I tried using a Left join Students to Attendance and then joining AttendanceCtrl but Access said it couldn't do it because of "ambiguous outer joins". It said to create the first join then use that query in the second join. I tried that. I created a query with a Left join joining Students to Attendance. That gives me what I wanted, all students from Students and also those students with matching records in Attendance.

The 2nd query is giving me problems. I tried joining the first query (qryStudents) to AttendanceCtrl and calculating my totals. Problem is, the query only gives me students what have records in the Attendance file; it doesn't give me all the students. If a student did not miss any days, I need to show that he was present 90 days out of 90. Because there's no matching record in the Attendance file, I get nothing for those students.

As I said the first query (qryStudents) seems to be working but I need to take the records from that query, group them together by StudentID, and then calculate my totals. How can I do this? Am I approaching this wrong altogether?

Thanks for any help.

View 1 Replies View Related

Returning Null Records?

Jan 14, 2008

Hello everyone.

I have just joined the forum and spent the last day or so looking around for an answer that I wasn't able to find.

I have been asked by my employer to capture details of who has signed our confidentiality policy. I have made a very simple database which only has three tables, EMPLOYEE, POLICY and VERSION.

EMPLOYEE has three fields, NAME, NUMBER and BRANCH. POLICY has three fields, NUMBER, DATE and VERSION. VERSION has two fields, VERSION NUMBER and DATE. I won't worry about the VERSION table any further in this post as it doesn't figure in the problem query.

Primary key for EMPLOYEE is NUMBER. Compound key for POLICY is NUMBER and DATE (ie. the employee can sign the policy more than once and we want to record when this was, and whether the policy version changed).

I have an Access "type 3" join defined in table relationships from EMPLOYEE.NUMBER to POLICY.NUMBER.

I am trying to write a query that returns the employees that haven't signed the policy. I have no problem returning the employees that have (ie. employees whose numbers match the numbers in the POLICY.NUMBER field), but it is the EMPLOYEE.NUMBER entries that are not present in POLICY.NUMBER that are causing me grief.

I have tried using the expression builder in the query builder window (it gave me <>[tblPolicy]![Number]) which doesn't return any records (I have over 490 in the database and should be getting back at least 50 or so).

Sorry if this question is too basic.

Can anyone offer me any advice here?

Thanks in anticipation.

John

View 2 Replies View Related

Returning Records On Query

Oct 5, 2004

I cannot seem to get my query to return all the records i want it to, i want to search by year group, which it is doing fine, but if a record has a table wich does not have data in it, the query will not return that record, i can't find the solution anywhere!

View 3 Replies View Related

Finding Duplicate Records

Jun 19, 2006

Hello

I've had to export data from an old third party database to Access with the task of reporting on the data. I have a client table and work tables, one for each year going back to 1992. In the original database, the clients do not have a date of when they were set up. I need to find out how long clients have been with us, so I thought of going back through the work tables 2006 to 1992 and finding out where they first occurred, by looking for duplicate records in the tables. Is this a simple enough thing to do? The client table and work tables are linked through the field Client.

Thanks

Dave, England

View 4 Replies View Related

Finding Records 3 Months Old

Mar 12, 2008

Can't think how I would do this. If I create a query with a certain date then it will need to be changed every time the query is run. How would I write a query that automatically looks for a date 3 months or more old.

Thanks for any help. :D

View 2 Replies View Related

Finding Records By Primary Key Value

Oct 26, 2004

I have a table, and there are many records, each with a unique value in the OrderNumber field

I have a text box on a form, and i want it to work so that the user types in a OrderNumber value, and it loads that record into the form (the form is bound to the table)

I already know how to load a record by record number, but how can i do it by OrderNumber value?


thanks

View 2 Replies View Related

Finding Records Between Dates

Jan 4, 2005

Hello, i need to have my database find records that were entered between two dates. To do this i made a query that included the dates the records needed to be in between....[date1] and [date2]. Then i had the record dates be called [sent date]. i made my query and in the criteria for [sent date] i wrote
(Between [Date1] And [Date2])
when i enter the two dates [date1] and [date2] the query does not show the records that are between that date. why is this happening? is there and easier way? another way?
For example, say that i have records with their [sent dates] equaling 12/30/2004, 1/1/2005, 10/1/2005
i want to make it so that when the user inputs a records with dates [date1] and [date2], that those records will show up if their [sent dates] are between [date1] and [date2]. if [date1] is 1/1/2003 and [date2] is 1/1/2006, all of the records will show up.
if [date1] is 12/31/2004 and [date2] is 1/3/2005, then only the record with the date 1/1/2005 will show up.
how can i do this?

View 5 Replies View Related

Finding Records Within One Table - Msg Box

Feb 17, 2005

I have patients and their details all listed in onetable.
I want a message box to come up if a patient also has a family memeber somewhere else in this table. To do this i need to
match surname and mother's christian name.
Ani ideas?

View 1 Replies View Related

Queries :: Finding Non-Zero Records

Aug 7, 2015

I have a table in Access that looks like:

fiscal_year acct_period loc_rc account afe description amount system
2015 6 01001028 745003 100050652John A Doe -69.72 E
2015 6 01001028 745003 100086599Jane Doe -33.37 E
2015 6 01001028 745003 100086599Jane Doe -587.69 E
2015 6 01001028 745003 994709 AP - EXPRPT050815SG - Jane Doe - 1 33.37 L
2015 6 01001028 745003 994709 AP - EXPRPT050815SG - Jane Doe - 2 587.69 L
2015 6 01001028 745003 994709 AP - EXPRPT05
2115PK - John A Doe - 1 69.72 L
2015 6 01001028 745006 100048910KROGER -389.74 E

It's combining data from 2 system Identified by E or L. The data is similar but not exact & I'm comparing it using the description. What I need Access to do is find the record that doesn't "zero-out". In the example above the record it should pull is the last one "Kroger $389.74". How to do this but I do have a query/report that will subtotal based on the LOC-RC field.

View 4 Replies View Related







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