Type Mismatch In Expression

Jun 5, 2006

This is an Access 2000 question.

Now, I know what the error message is supposed to mean, despite my total newbie-ness. My table Product has p/k ProdID (autonumber, long integer) and my table Items has ProdID (number, long integer) as a f/k. It's a one-to-many relationship (each Item is only one kind of Product, but each Product may have multiple Items.) But when I try to run a query in Access, I get the "Type mismatch in expression" error. The only relationship is between a number and an autonumber as described above.

Does anyone know what might be going on?

View Replies


ADVERTISEMENT

Type Mismatch In Expression???

May 26, 2005

hey,

can someone pls tell me why i get an Type mismatch in expression err with this code:

INSERT INTO tblACAD ( PROIZVAJALEC, TIP, DN, KOSOV )
SELECT tblsifrant.Proizvajalec, tblsifrant.Tip, tblsifrant.DN, tblsifrant.Kosov
FROM tblsifrant, tblACAD
WHERE (((tblsifrant.Sifra)=[tblACAD.TIP]) AND ((tblsifrant.DN)=[tblACAD.DN]) AND ((tblACAD.KOSOV)>0));

If i remove one criteria to get this code then there are no err, but thats not what i want:

INSERT INTO tblACAD ( PROIZVAJALEC, TIP, DN, KOSOV )
SELECT tblsifrant.Proizvajalec, tblsifrant.Tip, tblsifrant.DN, tblsifrant.Kosov
FROM tblsifrant, tblACAD
WHERE (((tblsifrant.Sifra)=[tblACAD.TIP]) AND ((tblACAD.KOSOV)>0));


I create this code in design view so all the names and tables are correct.

So does anyone have any ideas?

Thx

View 2 Replies View Related

Type Mismatch In Expression

Dec 20, 2005

Hi all,

I'm using DB to run a small poker league, here's my setup.

Tables:
players - player_id (autonumber), player_name (text)
tourn - tourn_id (autonumber), venue (text), entry_fee (number, currency), tourn_date (date/time, medium date), n_entrants (number, integer<>0)
status - status_id (autonumber), player_name (from players table), tourn_id (from tourn table), position (number, integer<>0), winnings (number, currency)

I'm trying to create a query, that groups by player name, the count of tourn_id, victories (count of position=1), cash_prizes (count of winnings>0), sum of winnings, sum of entry_fee, net winnings (sum of winnings - sum of entry_fee)


With the help of someone else, I get this, but I keep getting error msg "type mismatch in expression"

SELECT P.player_name, Count(T.tourn_id) AS CountOftourn_id, Sum(S.winnings) AS SumOfwinnings, Sum(T.entry_fee) AS SumOfentry_fee, (SELECT Count(position) FROM status WHERE position =1
AND status.player_name= P.Player_Name) AS victories, (SELECT Count(winnings) FROM status WHERE winnings>0
AND status.player_name= P.Player_Name) AS Cash_prizes
FROM tourn AS T INNER JOIN (players AS P INNER JOIN status AS S ON P.player_name=S.player_name) ON T.tourn_id=S.tourn_id
GROUP BY P.player_name;

What's wrong with the above?

Thanks in advance

Raju

View 5 Replies View Related

Type Mismatch In JOIN Expression

Aug 15, 2005

I don't quite understand this error message, and therefore cannot begin to fix it. One of my forms will not open except in design view because of a "Type Mismatch in JOIN expression" error. Can someone please tell me where to look to fix it? Thanks.

View 5 Replies View Related

Data Type Mismatch In Criteria Expression

Jul 18, 2005

I am getting the error "Data type mismatch in criteria expression" when I put sorting on the following field in a query:

3 Month Date: DateAdd("m",+3,[Current Date])

If I remove sorting the query works fine. When I add sorting to this column in the query design grid, I get the error message.

Any ideas?

Thanks,
BJS

View 8 Replies View Related

Data Type Mismatch In Criteria Expression

Apr 11, 2006

can someone tell me why I getting this error when I try and run this query:

select distinct case_id
from NOLDBA_RPT_CASE_CHG_IND G

where
sys_curr_date between '01/01/2005' and '12/31/2005'
and aft_case_status = 'O'

and not exists
( select 1 from NOLDBA_RPT_CASE_CHG_IND X
where X.case_id = G.case_id
and X.aft_case_status = 'C'
and X.sys_curr_date = G.sys_curr_date )

Thanks

View 4 Replies View Related

Data Type Mismatch In Criteria Expression

Apr 3, 2008

Hi All

I would be much obliged if someone would help me here.

I have the following code which takes a value from a combobox and uses it in an sql statment to find a certain record and then it populates the GUI with that recordset , however I get the following error "Data type mismatch in criteria expression"

Please help

CODE:

Private Sub cmdSearch_Click()

Dim sql As String
Dim rsUpdate As New ADODB.Recordset


On Error GoTo DbError

sql = "SELECT * FROM ServiceReport WHERE CallReferenceNo= " & Me.cboSearchRef.Value


rsUpdate.CursorType = adOpenDynamic
rsUpdate.LockType = adLockOptimistic

rsUpdate.Open sql, remoteConnection, , , adCmdText

If rsCategories.EOF = False Then
Me.txtDate = rsCategories!Date
Me.cboModel = rsCategories!Equipment
Me.txtHK = rsCategories!HongKongFaultNo
Me.txtInvoice = rsCategories!InvoiceNo
Me.txtRef = rsCategories!CallReferenceNo
Me.txtSerial = rsCategories!SerialNo
Me.txtSite = rsCategories!Site
Me.cboClient = rsCategories!Client
Me.chkCompleted = rsCategories!Completed
Me.chkHK = rsCategories!HK
Me.chkRepaired = rsCategories!Repaired
Me.chkSpares = rsCategories!Spares
Me.chkTested = rsCategories!Tested
Me.cldComp = rsCategories!CompletedDate
Me.cldExp = rsCategories!ExpectedDate
End If



MsgBox "Record Found.", vbInformation

rsCategories.Close
SetRecordset

Exit Sub

DbError:

MsgBox "There was a freakin error finding that record, go figure." & Err.Number & ", " & Err.Description

End Sub


THANKS

View 3 Replies View Related

Data Type Mismatch In Criteria Expression

Feb 8, 2006

hi guys, here is my problem.the error in the title appears when i try to update a record.the field MODON in the table is defined as a short date and an input date 00/00/0000.Here is the code where i insert and update the records: Option Compare DatabaseOption ExplicitPrivate Sub Command4_Click()On Error GoTo Err_Command4_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmCalendar" DoCmd.OpenForm "frmCalendar", , , , , acDialog, Me.name & ";modon"Exit_Command4_Click: Exit SubErr_Command4_Click: MsgBox Err.description Resume Exit_Command4_Click End SubPrivate Sub Command15_Click()Dim str1 As DateOn Error GoTo Err_Command15_Click 'DoCmd.SetWarnings False If DCount("[comment]", "comments", "[change_id]=" & Me.Task_Num & "") = 0 Then MsgBox "insert" DoCmd.RunSQL "insert into [comments] (change_id,modon,comment,modby,modif) values (" & Me.Task_Num.Value & ",'" & Me.modon.Value & "','" & Me.Text10.Value & "','" & Forms!Login!username1 & "','" & Now() & "');" DoCmd.SetWarnings True Else MsgBox "update" MsgBox DLookup("[comment]", "comments", "[modon]='" & CStr(Me.modon.Value) & "'") DoCmd.RunSQL "update [comments] set comment='" & Me.Text10.Value & "' where change_id=" & Me.Task_Num & " and [modon]='" & Format(str1, "dd/mm/yyyy") & "';" DoCmd.RunSQL "update [comments] set modby='" & Forms!Login!username1 & "' where change_id=" & Me.Task_Num & " and [modon]='" & Me.modon.Value & "';" DoCmd.RunSQL "update [comments] set modif='" & Now() & "' where change_id=" & Me.Task_Num & " and [modon]='" & Me.modon.Value & "';" End If DoCmd.SetWarnings True Exit_Command15_Click: Exit SubErr_Command15_Click: MsgBox Err.description Resume Exit_Command15_Click End SubPrivate Sub Command16_Click()On Error GoTo Err_Command16_Click DoCmd.CloseExit_Command16_Click: Exit SubErr_Command16_Click: MsgBox Err.description Resume Exit_Command16_Click End SubPrivate Sub Command4_Exit(Cancel As Integer) If IsEmpty(Me.modon) Then MsgBox "Please, select a date for the minute" Me.modon.SetFocus Else Me.Task_Num.Visible = True End IfEnd SubPrivate Sub Form_Load() Me.Text13.Visible = False Me.Text10.Visible = False Me.Label12.Visible = False Me.Label9.Visible = False Me.Task_Num.Visible = FalseEnd SubPrivate Sub task_num_AfterUpdate() If IsEmpty(Me.Task_Num) Then MsgBox "Please, select a task Number" Me.Task_Num.SetFocus Else Me.Text13.Visible = True Me.Text10.Visible = True Me.Label12.Visible = True Me.Label9.Visible = True Me.Text13 = DLookup("[description]", "newchange", "[change_id]=" & Me.Task_Num & "") Me.text10 = DLookup("[comment]", "comments", "[change_id]=" & Task_Num & " and [modon]='" & Me.modon.value & "'") End IfEnd Subthx in advance....

View 2 Replies View Related

Data Type Mismatch In Criteria Expression. Where?

Feb 26, 2006

I am trying to set a recordset, and I keep getting this data type mismatch error, but I cannot see what the problem is. Here's my code:

Set rstAccounts = dtbCurrent.CreateQueryDef("", "SELECT [Account ID], [Balance] FROM tblAccounts WHERE [Account ID]='" & txtAccountID.Value & "';").OpenRecordset

txt.AccountID.Value is 1, and when I hard code the value as 1 it works, so I'm not sure what the problem is. I've tried using CStr() to convert it to a string, CInt() to convert it to a integer (even though it already is one), with using both quotes, with only double quotes, and with only single quotes. It's driving me crazy, because i'm sure it's something really simple, but I'm not sure what else to try.


Thanks in advance.

View 4 Replies View Related

Queries :: Keep Getting - Type Mismatch In Expression - Error

Dec 1, 2014

I've been trying to get a query to run but I keep the "type mismatch in expression" error message.It's the Invoice-Product Query in the attached file.I have tried changing the field types, the primary keys and messed around with the relationships but noting seems to work.

View 2 Replies View Related

Modules & VBA :: Data Type Mismatch In Criteria Expression

Nov 8, 2014

The error I'm getting is "data type mismatch in criteria expression".

Private Sub BtnAddBooking_Click()
Dim CustomerID As String
Dim StaffID As String
Dim intPos As Integer
Dim strSQL As String
Dim strSQL2 As String
Dim BathValue As Integer
Dim rst As DAO.Recordset
Dim RemainingBookingExists As String
Dim RemainingBaths As Integer
Dim RemainingBathsExists As String

[code]....

View 2 Replies View Related

Queries :: Data Type Mismatch In Criteria Expression?

Apr 29, 2014

I have a query which runs fine until I set a criteria (of True) in the field

Code:
chase_it: prevwd([practice_bacs_submission_date])<Date()

So without the criteria, I have

Code:
SELECT prevwd([practice_bacs_submission_date])<Date() AS chase_it, practice_bacs.practice_bacs_submission_date
FROM practice_bacs
WHERE (((practice_bacs.practice_bacs_submission_date)>#1/31/2013#));

and in the query results I see 0 and -1 as expected for the 'chase_it' expression BUT When I add True (or -1, or 0) as a criteria for 'chase_it', I get the "Data type mismatch in criteria expression" error.So the sql that fails is

Code:
SELECT prevwd([practice_bacs_submission_date])<Date() AS chase_it, practice_bacs.practice_bacs_submission_date
FROM practice_bacs
WHERE (((prevwd([practice_bacs_submission_date])<Date())=True) AND ((practice_bacs.practice_bacs_submission_date)>#1/31/2013#));

In case it's relevant, my function prevwd is:

Code:
Function prevwd(dt As Date) As Date
10 On Error GoTo prevwd_Error
20 dt = dt - 1
30 While Weekday([dt]) = 1 Or Weekday([dt]) = 7 Or IsBankHoliday(dt)

[code]...

and this function is used extensively and always works perfectly. I have tried using DateAdd instead of dt = dt - 1, but that made no difference.

View 14 Replies View Related

Error - Data Type Mismatch In Criteria Expression

Nov 22, 2011

I am creating a simple query in a farm audit database.

In criteria of the customers field, i have entered "Farmer One" as this is the customers data which I want to retrieve and in the Totals section I have changed the setting to Where instead of group by, but I am still getting "Data type mismatch in criteria expression" popping up.why this is?

View 2 Replies View Related

Invalid Format? Data Type Mismatch In Criteria Expression

Jan 30, 2008

Hi,

I am trying to insert a text box value into a text field value in a table. I am checking to see if the value is already in the table but come across an error on the second click. The first click enters the number, and the second click gets error. I know where the error is but I'm not sure why or how to fix it.

Code:Dim db As DAO.DatabaseDim rs As DAO.RecordsetSet db = CurrentDb()Set rs = CurrentDb.OpenRecordset("CVHOLD", dbOpenDynaset)If Not rs.BOF Then rs.MoveFirstrs.FindFirst "[Batch Number] = " & Me![Batch Number]'Error here on second passIf (rs.EOF) Then 'Seems to insert new record properly 'No Batch Number in Table yet. rs.AddNew rs("Batch Number") = Me![Batch Number] rs("Date Closed") = Now() rs.Update rs.CloseElse 'never enters, jumps to Error label 'Batch already listed in table MsgBox ("Batch already in table. Updating Closed date")End IfErr_cmdHoldStatus_Click: MsgBox Err.Description

This is what the debugger outputs for my values
Code:Me![Batch Number] : 81697 : Object/Textbox rs("Batch Number") : "81697" : Object/Field rs.BOF : False : Boolean rs.EOF : False : Boolean

View 1 Replies View Related

Modules & VBA :: Run Time Error - Data Type Mismatch In Criteria Expression

Aug 11, 2014

I am getting Run-time error '3464': Data type mismatch in criteria expression when i execute the code:

Option Compare Database
Dim rst As DAO.Recordset
Dim rst1 As DAO.Recordset
Public verificacoes As Boolean

[code]....

View 5 Replies View Related

Modules & VBA :: Fields In Text And Number Format - Type Mismatch In Expression

Oct 29, 2013

I have two tables in a query joined by a ID field. The problem is in the one table the ID fiels is a text format and in the other table its a number format so the query builder doesnt like that and gives me the Type mismatch in expression error.

There's no way around it though; i need it to be those formats in its respective tables for reasons i wont go into here for simplicity.

View 2 Replies View Related

General :: Error 3464 / Data Type Mismatch In Criteria Expression

Jun 23, 2012

"Data type mismatch in criteria expression" Error 3464

I get this on the <DoCmd.OpenForm "frmWrittenStatements"> in my code.

How on earth are any criteria attached to this?

View 2 Replies View Related

Queries :: Combination Of Letters And Numbers = Data Type Mismatch In Criteria Expression

May 16, 2013

I am working on a fairly ancient manufacturing database that identifies items using a combination of letters and numbers. The usual format is to have a letter (which suggests something about the item type) followed by a sequence of numbers.

I am trying to write a query that looks up all the records beginning with a prefix or arbitrary length, strips away the text, and finds the highest number.

Code:

SELECT Right(LocalID,Len(LocalID) - 1) As IDSuffix
FROM tblItemIDCrossReference
WHERE Left(LocalID,1) = 'T' AND IsNumeric(Right(LocalID,Len(LocalID) - 1)=True)

This query produces the error given in the title of this thread, whilst the following works:

Code:

SELECT Right(LocalID,Len(LocalID) - 1) As IDSuffix
FROM tblItemIDCrossReference
WHERE Left(LocalID,1) = 'T' AND IsNumeric(Right(LocalID,5)=True)

This related query also works and shows a load of -1s and 0s correctly

Code:

SELECT Right(LocalID,Len(LocalID) - 1) As IDSuffix,
IsNumeric(Right(LocalID,Len(LocalID) - 1)=True) As Alias
FROM tblItemIDCrossReference
WHERE Left(LocalID,1) = 'T' AND

But once again shows the error message when I try to filter the field Alias to -1 or 0 only through the right-click menu.I have tried piping Len(LocalID)-1 through CLng, CInt, Int, CDbl and CSng; this changes the error to 'Invalid Use Of Null' I have also tried removing the '=True' from the IsNumeric() term.

View 2 Replies View Related

Queries :: Balance Update Query - Data Type Mismatch In Criteria Expression

Jul 25, 2013

I have an update query for tGLCashAccount where it adds a value from another table with the BeginningBalance to arrive at CurrentBalance.

Here's what it looks like in design view:

Field: CurrentBalance
Table: tGLCashAcct
Update to: [tMakeNewCashBal].[TotalPrice]+[tGLCashAcct].[BeginningBalance]

Here is SQL code:
UPDATE tGLCashAcct, tMakeNewCashBal SET tGLCashAcct.CurrentBalance = [tMakeNewCashBal].[TotalPrice]+[tGLCashAcct].[BeginningBalance]
WHERE (((tGLCashAcct.GLCashAcctID)="102"));

I get the error: data type mismatch in criteria expression when I run it.

View 3 Replies View Related

Passing Parameters Thru Combo Selection: ERROR:Data Type Mismatch Criteria Expression

Oct 17, 2006

I am trying to pass parameters to my qury thru my combo selection. I keep getting this error "Data type mismatch criteria expression", does anyone have an idea why?
WHERE (((fShiftWorked([tblTimeLog].[timeStart])=[Forms]![frmOperatorWorkDone]![cboShift] Or IsNull([Forms]![frmOperatorWorkDone]![cboShift]))=True));


I have spent so much time onthis already and i am sick of it :mad:


Attached is my db. Please help me out here.

View 2 Replies View Related

Delete Certain Records Based On Selected Date - Data Type Mismatch In Criteria Expression

Aug 24, 2015

I want to delete certain records based on the selected date. However, I come across with this is error - Run time error '3464' (Data type mismatch in criteria expression).This part is highlighted in yellow. I even used the debug.print to test out if the sql statement is executed properly.

Code:
DoCmd.RunSQL DelSummarySQL

Here is my full code

Code:
Private Sub cmd_Delete_Click()
Dim DelSummarySQL As String
Dim StartRange As Date

[code]...

View 2 Replies View Related

13 - Type Mismatch

Oct 21, 2005

Hi

I posted this on the end of the audit trail thread but nobody was really looking at it. I have used the script for the audit trail, and when I start changing any of the records, it comes up with the error:

13 - Type Mismatch

When I ctrl - break, and debug, it highlights the last line of the script:

On Error GoTo Form_BeforeUpdate_Err

Call Audit_Trail(Me)

Form_BeforeUpdate_Exit:
Exit Sub

Form_BeforeUpdate_Err:
MsgBox Err.Number & " - " & Err.Description
Resume Form_BeforeUpdate_Exit

Anyone any ideas on what is happening?

View 6 Replies View Related

Type Mismatch!!??

Nov 8, 2006

Hi all,
I have a problem with the following piece of code:

Private Sub cmdCautare_Click()
Dim strSQL As String, strOrder As String, strWhere As String
'Select Case Me.cmbTipVersus
'Case 1
'If Me.cmbTipVersus = "" Then
strSQL = "SELECT tblDosare.DosarID, tblDosare.DenumireDosar, tblDosare.CodDosar, tblDosare.DataDosar, tblInstante.Localitate, tblStadiu.Data, tblStadiu.Stadiu FROM tblInstante INNER JOIN (tblDosare LEFT JOIN tblStadiu ON tblDosare.DosarID = tblStadiu.Dosar) ON tblInstante.InstantaID = tblDosare.Instanta"
strWhere = "WHERE"
strOrder = "ORDER BY DosarID"
If IsNull(Me.txtDenumire) Or Me.txtDenumire = "" Then
Else
strWhere = strWhere & "(DenumireDosar) Like '*" & Me.txtDenumire & "*'"
End If
If IsNull(Me.cmbStadiu) Or Me.cmbStadiu = "" Then
Else
strWhere = strWhere & "(DenumireDosar) Like '" & Me.txtDenumire & "*' & " And " & (Stadiu) Like '" & Me.cmbStadiu & "*'"
End If
DoCmd.OpenForm "frmRezultateCautare", acNormal
Forms!frmRezultateCautare!lstRezultate.RowSource = strSQL & " " & strWhere & "" & strOrder
'End If
'End Select
End Sub

And on this line strWhere = strWhere & "(DenumireDosar) Like '" & Me.txtDenumire & "*' & " And " & (Stadiu) Like '" & Me.cmbStadiu & "*'"
i have an error message type mismatch. If i do the search only with the first text box the code works hjust fine but if i make the search w.r. with the second control (combo box cmbStadiu) the error appears. If anyone can help i will appreciate it.
Thank you all!

View 4 Replies View Related

Type Mismatch

Sep 13, 2004

I am persistently getting the "Error Number:13; Type Mismatch" with the code below.
Any help is greatly appreciated...
BTW, in the SQL string, i will like to have the wildcard as "*" but the VB Editor automatically changes it to " * "... can that be a problem??

Code:


Dim db As DAO.database
Dim qdf As DAO.QueryDef
Dim sqlsearch As String

Set db = CurrentDb

If Not QueryExists("Q_Paint") Then
Set qdf = db.CreateQueryDef("Q_Paint")
Else
Set qdf = db.QueryDefs("Q_Paint")
End If

sqlsearch = "SELECT M_Paint.* From M_Paint " & _
"WHERE M_Paint.Color_Number = '" * " & "Me.txb_pcn_colornumber" & " * "';"

qdf.SQL = sqlsearch

DoCmd.OpenForm "F_Display_Paint"
DoCmd.Close acForm, "F_Paint_Catcodesearch"
DoCmd.Close acForm, "F_Search_Paint"

View 2 Replies View Related

Type Mismatch

Dec 29, 2005

WHy whould this be a type mismatch?

Dim strLABCHECK As Integer

strLABCHECK = CInt(StrComp(strSymbol, "(LAB)"))
If (Len(strSymbol) < 6 & Len(strSymbol) > 1 & strLABCHECK < 0) Then
...
End if

View 2 Replies View Related

Data Type Mismatch...

Jan 10, 2007

Ive been working at this problem for a while now and I can't figure it out. I have a table full of Work Orders, and on the form for inputing the Work Order data, there is a field for the date that the WO was received, and the date it is wanted. There is also a field that tells if this was a rush job (Yes/No) field.

I need to make a query that will grab all the rush jobs, and sort by how many days were between the date received and date wanted. This would be easy, just subtracting the dates, but I need to have it not include weekends and holidays. I found an algorithm to do that and it seems to work well. However, when I run the query, it gives me a "Data type mismatch in criteria expression." error. At this point, to debug it, I put in a message box to see if it processes any entries. It does process them one at a time, but once it gets to a certain point I get that error. I have checked all the dates, making sure they are all valid and they are. I'm just really stumped here. Here is the code for my query:

SELECT [Usable Orders].[AI Number], [Usable Orders].[District Name], [Usable Orders].[CCM Name], [Usable Orders].[8255 Received], [Usable Orders].[Date Wanted], [Usable Orders].Rush, WorkingDays2([8255 Received],[Date Wanted],[AI Number]) AS [Working Days]
FROM [Usable Orders]
GROUP BY [Usable Orders].[AI Number], [Usable Orders].[District Name], [Usable Orders].[CCM Name], [Usable Orders].[8255 Received], [Usable Orders].[Date Wanted], [Usable Orders].Rush
HAVING ((([Usable Orders].Rush)="Yes") AND ((WorkingDays2([8255 Received],[Date Wanted],[AI Number]))<=10));


and here is the code for my WorkingDays2 (counts all working days excluding holidays) the AINumber field I put in for debugging purposes to see which entries were being processed.


Public Function WorkingDays2(StartDate As Date, EndDate As Date, AINumber As String) As Integer
'................................................. ...................
' Name: WorkingDays2
' Inputs: StartDate As Date
' EndDate As Date
' Returns: Integer
' Author: Arvin Meyer
' Date: May 5,2002
' Comment: Accepts two dates and returns the number of weekdays between them
' Note that this function has been modified to account for holidays. It requires a table
' named tblHolidays with a field named HolidayDate.
'................................................. ...................
On Error GoTo Err_WorkingDays2

Dim intCount As Integer
Dim rs As Object
Dim stSql As String
Dim con As Object
Dim Message As String

If StartDate > EndDate Then
MsgBox "Start Date is After End Date"
WorkingDays2 = -1
GoTo Exit_WorkingDays2
End If

stSql = "SELECT [HolidayDate] FROM tblHolidays"

'StartDate = StartDate + 1
'To count StartDate as the 1st day comment out the line above

intCount = 0
Set con = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.Recordset")
rs.Open stSql, con, 1 ' 1 = adOpenKeyset
'MsgBox "Today is " & Weekday(StartDate) & ", " & StartDate & "Opening AI Number is " & AINumber
Do While StartDate <= EndDate
rs.Find "[HolidayDate] = #" & StartDate & "#"
If Weekday(StartDate) <> vbSunday And Weekday(StartDate) <> vbSaturday Then
If rs.EOF Then
intCount = intCount + 1
' Message = Message & " and today is a work day."
End If
Else
' Message = Message & "and today is not a work day."
End If
' MsgBox Message
'rs.MoveNext
StartDate = StartDate + 1
Loop
'MsgBox "Closing AI Number " & AINumber & "Count is " & intCount
'MsgBox "After Loop count is " & intCount & " and today is " & StartDate
WorkingDays2 = intCount
'MsgBox "Date is " & StartDate & "AI Number is " & AINumber & " and there were " & intCount & " days."
Exit_WorkingDays2:
Exit Function

Err_WorkingDays2:
Select Case Err

Case Else
MsgBox Err.Description & "Start date is " & StartDate & "End Date is " & EndDate
Resume Exit_WorkingDays2
End Select

End Function

View 1 Replies View Related







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