Queries :: Data Type Mismatch For Date

Jul 17, 2014

I'm trying to create a query based on another query. However, my WHERE statement is causing a data type mismatch for a date. My code is:

Code:
SELECT id, status, updated, [previous renewal]
FROM qrynext renewal
WHERE status = "active" and [previous renewal] = date()

If I remove the " and [previous renewal] = date()" it works just fine. But even setting up [previous renewal] to equal #7/17/14# or "07/17/14" or anything else I've tried won't work. The field that it's based on is definitely a date field, but I don't know why it would cause a data type mismatch.

View Replies


ADVERTISEMENT

Date Parameter Cause 'data Type Mismatch Error'

May 5, 2005

hi

I'm writing a pretty simple application to search an Access db. The query is:

Me.cmdSelectEvents.CommandText = "SELECT eventDetails.id, eventDetails.subject, " & _
"eventDetails.title, eventDetails.trainers, eventDetails.type, eventDetails.summary, " & _
"eventDetails.url, eventDates.date " & _
"FROM eventDates INNER JOIN eventDetails ON eventDates.id = eventDetails.id " & _
"WHERE (((eventDetails.subject)=@subject) AND ((eventDetails.type)=@type) AND ((eventDates.date)<@date));"

The parameters @subject and @type are simply strings selected from dropdown values.

The @date parameter is set by using a dropdown to select a timeframe to search in, specifically "Within 1 month", "Within 3 months", "Within 6 months". These options have the values "1", "3" and "6".

When the form is submitted the value of the selected option is passed into the following routine:

Dim valSelectedDate AsInteger
Dim dateParameter AsDate
valSelectedDate = ddlDate.SelectedValue
dateParameter = DateAdd("m", valSelectedDate, (Date.Now))
cmdSelectEvents.Parameters("@date").Value = dateParameter

When I run the debugger the right date value seems to be being passed to the sql query (i.e. if the user selects "within 6 months" and today's date is 5th May 2005, then #05/11/2005# is passed as the parameter) but I get the error data type mismatch. The column eventDates.date is a Date/Time column.

Can anyone help?

View 3 Replies View Related

Criteria For Date Field Causing 'data Type Mismatch' Error

Jul 31, 2005

Hi,

I have a query with a field defined in the query as follows:

Next Bill Date:
IIf(IsNull([dtmLastBillDate]),
DateSerial(Year([dtmDateRecd]),Month([dtmDateRecd])+1,15),
DateSerial(Year([dtmLastBillDate]),Month([dtmLastBillDate])+[lngNumMonths],15))

I can't seem to set any criteria for this field without getting an error:
'Data Type Mismatch in Criteria Expression'

Examples of criteria that I've tried:
=#1/1/2005#
>#1/1/2005#
=Date()
Year([Next Bill Date]) = Year(Now())

All of the above generate that same error.
{I've seen many pages/posts regarding 'data type mismatch' but none seem to relate directly to this situation.}

I could use some help, fast!

Thanks in advance,
David

View 1 Replies View Related

Queries :: Data Type Mismatch In Criteria Error

Aug 8, 2013

I am getting this error in a query. The field generating the error is a calculated field using a custom function.The function is:

Code:

Public Function DecimalTime(dblEvalTime As Double) As Double
DecimalTime = Hour(dblEvalTime)
DecimalTime = DecimalTime + (Minute(dblEvalTime) / 60)
DecimalTime = DecimalTime + ((Second(dblEvalTime) / 60) / 60)
DecimalTime = Round(DecimalTime, 2)
End Function

The dbalEvalTime parameter is passed in to the function as (DateIn+TimeIn)-(DateOut+TimeOut).

So the data type passed in is Double and the Function result is Double. The criteria i am applying in the query is simply <0.01. I have formatted the query field as #.00, 0.00 and General Number but it makes no difference.

I have also tried creating a second query using the first as its data source and applying the criteria in that query but still get the same error. Without the criteria the query runs fine.

View 12 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

Queries :: DateDiff And Varchar Dates - Data Type Mismatch

Mar 17, 2015

So I am working with a table that has 2 text fields called DestructionMonth and DestructionYear. The data in DestructionMonth is a 2 character month (01 through 12), and year is a 4 character field.

What I need to do is find all records where the destructiondate is within 60 days/2 months.

I have tried this many different ways and am still getting an error.

So this query works fine:

SELECT documentstable.destructionmonth, documentstable.destructionyear, documentstable.id, Now() AS Expr1, Date() AS Expr2, DateAdd('m',2,destructionyear+"/"+destructionmonth) AS Expr3, Format(destructionyear+"/"+destructionmonth+"/"+"01","Short Date") AS Expr4, CInt(DateDiff("d",Format(destructionyear+"/"+destructionmonth+"/"+"01","Short Date"),Date())) AS MyDateDiff
FROM documentstable

It gives me MyDateDiff in the last column, the difference between the destructiondate and the current date. That works great.

But if I add a where clause with this:
CInt(DateDiff("d",Format(destructionyear+"/"+destructionmonth+"/"+"01","Short Date"),Date())) < 60

I get "Data Type Mismatch in criteria expression".

The value I am comparing to the 60 is an integer! How is it a mismatch?! Removing the CInt (which I had though was unnecessary anyway) doesn't work.

View 7 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

Queries :: Inventory Transaction Form - Append Query Data Type Mismatch

Dec 8, 2014

I'm receiving an error indicating there is a data type mismatch when running a query named qappInventoryTakeOn.

Data is entered into the Inventory Transaction Form. If the transaction type is "Take On", when the update button is clicked the record will be saved to tblInventoryMovements and then qappInventoryTakeOn should run to update tblInventory, but I keep running into the aforementioned error.

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

Queries :: Average Calculated Field From A Previous Query - Crosstab Data Type Mismatch

Jun 3, 2014

I am trying to construct a crosstab that averages a calculated field from a previous query. It is returning a "Data Type Mismatch" message.

The field I am trying to average is a subtraction of dates to find total days. I assume my field is not a number so I have tried to wrap it in CDbl() to change the type.

The formula is

Code:
CASE_DAYS: CDbl(IIf([Actual Close Date]-[Creation Date]>=0,[Actual Close Date]-[Creation Date],""))

View 5 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

Data Type Mismatch?

Sep 6, 2007

I don't understand why this won't work.

I have a date field in a table. The default value for this field is Date().

The data type is Date/Time

The field is called Import Date.

Here is what I am trying to do in a query:

Month Imported: DatePart('m', 'Import Date')

I am getting a data type mismatch, and I don't see how.

If I put this:

Month Imported: DatePart('m', Date())

It works fine.

View 8 Replies View Related

Data Type Mismatch?

Jan 23, 2008

I am querying results using Access 97(Yes its old and no my company is not willing to upgrade.....:confused:). Anyhow, I am connecting to a corporate database that has two tables I am querying that should be joined on one field (wmg.wmgtk01_tnk.sys_i = wmg.wmgwo04_halfleg_actl.tnk_sys_i). I am running into a problem with these fields because they have been defined differently by my IT department. The "sys_i" field is a NUMBER of length 5, while the "tnk_sys_i" field is a NUMBER of length 20. Is there a way that I can trick Access into joining these fields even though they do not match? I am currently getting a "Data Type Mismatch" error when I attempt to create this join.

Thanks in advance for your help!

View 3 Replies View Related

Data Type Mismatch...

Mar 1, 2005

I've been studying unbound for quite awhile and i've build to forms but i seem to get stumped with datatype mismatch. I've tried everything that i would possibly know. I guess i'm just to new in access to try this but it's the only thing that works for what i'm trying to do can some1 please provide me some assistance. I've attached both forms. YOUR HELP WILL BE GREATLY appreciated.

Now the problem, when adding or editing info i get datatype mismatch -21233 some number of that sort....

Thanks...
Eddie...

View 14 Replies View Related

Data Type Mismatch

Aug 1, 2006

Dear All:

I am trying to print letters from access using a command button. It works well, but when I try to print the displayed record, I get "Data type mismatch in criteria expression".

The primary key is a 9-digit number where some have a leading zero. I have made this as text so I do not loose the leading zero.

Here is the code when the command button is pressed:

Private Sub Command1315_Click()
Dim strWhere As String
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print" _
, vbInformation, "Select a Record"
Else
'The Student ID Number is the name of the Primary Key

strWhere = "[STUDENT_ID] = " & Me.[STUDENT_ID]
DoCmd.OpenReport "HONORS_LETTER", acViewPreview, , strWhere
End If
End Sub

Thanks for all the help.

Dion

View 1 Replies View Related

Data Type Mismatch With InStr

Jul 22, 2005

Hi,

I'm having some problems with a simple query and it's driving me nuts. The invoice numbers in our system have hyphens in them, and I'm trying to find invoice numbers whose part before the hyphen matches a number I enter. Here's my SQL:

SELECT dbo_NIHB_ClaimLog.InvoiceNum, Left([InvoiceNum],InStr([InvoiceNum],"-")-1) AS InvoiceNumLeft
FROM dbo_NIHB_ClaimLog
WHERE (((dbo_NIHB_ClaimLog.InvoiceNum) Is Not Null) AND ((Left([InvoiceNum],InStr([InvoiceNum],"-")-1))=23316));

I'm getting a "Data Type Mismatch In Criteria Expression" error, and I can't figure out why. I've wrapped a Clng() around the Left() function, but that doesn't help either.

Am I missing something here?

View 5 Replies View Related

Autonumber Data/Type Mismatch

Aug 20, 2007

I have two tables, one has the autonumber column, sysid, and then in the process of updating the database via forms the sysid from one table is placed in another (text format). I thought I could use that to link the tables for queries, but I am running into a data/type mismatch error.

Any ideas to get around this?

Thanks!

View 2 Replies View Related

Sort & Data Type Mismatch

Dec 20, 2004

Hi. I was doing a simple query that resulted in a "data type mismatch in criteria expression" error. Hunting around for the source I realized that when I attempt to sort a column of numerical data a hidden decimal point is inserted and what should be an order of : 45, 10, 9, 2, becomes this order: 9, 45, 2, 10 (i.e., 9, 4.5, 2, 1.0)

Does anyone know what has happened?

moondog

View 1 Replies View Related

Data Type Mismatch Error

Jan 26, 2006

Hi

I am getting the following error when I try to present some information from a database:

Microsoft JET Database Engine error '80040e07'
Data type mismatch in criteria expression.
/tribute2.asp, line 168

The code relating to this is:
The error line it is talking about is:
Code:rsGuestbook.Open SQLstr, adocon

Code: <%Dim adoCon 'Holds the Database Connection ObjectDim rsGuestbook'Holds the recordset for the records in the databaseDim SQLstr'Holds the SQL query for the databaseSet adoCon = Server.CreateObject("ADODB.Connection")adoCon.Open = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=c:inetpubftprootlocalusericlay
emember ing.co.nzdb
emembering.mdb;"strcustomerID = Request.QueryString("remID")Set rsGuestbook = Server.CreateObject("ADODB.Recordset") sqlstr = "select * from guestbook where guestbook.mid =" & strcustomeridrsGuestbook.Open SQLstr, adoconDo While not rsGuestbook.EOF'Write the HTML to display the current record in the recordsetResponse.Write ("<font face='Arial' size='2' color='#000080'><i>A tribute provided by ")Response.Write (rsGuestbook("confirstname"))Response.Write (" ")Response.Write (rsGuestbook("conlastname"))Response.Write ("</i></font><font face='Arial' size='1' color='#000080'><i> ")Response.Write (rsGuestbook("conrelationship"))Response.Write ("</i></font><br><br>")Response.Write (rsGuestbook("conmessage"))Response.Write ("<br>")'Move to the next record in the recordsetrsGuestbook.MoveNextLoop'Reset server objectsrsGuestbook.CloseSet rsGuestbook = NothingSet adoCon = Nothing%>

Can anyone see where I have gone wrong ... could it be something to do with the fact that 'remid' relates to another table in the database. Though when I did a reponse write on the sqlstr it is presenting the remid.

Hope this doesn't sound to confusing.

View 8 Replies View Related

Date Import From Excel To Access - Type Mismatch Error

Sep 17, 2014

So I have a macro in excel which imports data from the excel sheet to a table in access db. Now the excel file has 4 columns which have dates.

- I imported the excel file from access via access so that I can get the heading of the table and the table is created. Then I deleted all the data in the table.

- When the table was imported 2 of the date columns got set as Short/text data type. Dont know why.

- Now, if I leave the data type as it is in Access table, my macro button in EXCEL works fine and imports the data to Access. If I change the data type, in access design, of the two data columns to date type, I get the type mismatch error when I run the import macro button in EXCEL. I am going nuts over this error. I even created a blank table in access and defined data types to all columns which would be imported from excel. but still excel macro button shows the same error.

I checked the format of all the four date columns is date.

I did a lot of hit and try and could it be the case that if access table fields are defined properly, but any of the data columns cells in excel sheet is null/empty, it will show the type mismatch error.

is it possible and is there a way, that once the data is imported to access, I can convert the value in the column from short text to date type.

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

Change Data Type/ Join Mismatch

Apr 30, 2006

Looks like mismatched join types has caused others plenty of headaches in the past!!
I am trying to create a query that connects 2 separate areas of our factory.
The first table (Table 1) has a field called prod_code which is a text field and this code (5 digit number) describes a manufactured product.
The next table (Table 2) also has a field called prod_code which is also a text field, is a different 5 digit number, and describes the same product but after packaging.
There is a 3rd table which I want to use to link both of these tables, but in table 3:
table 1. prod_code = table 3.item_code, and is a long integer. and table 2.prod_code = table3.item_code_prnt, also a long integer.
I need to be able to use table 3 to correlate data from tables 1 and 2.
I suspect I need to use Clng or similar but am unsure how to apply it.
Have been trying to construct an expression but continually get error (bracketing error, join mismatch etc, etc)
Any clues?

View 3 Replies View Related

Data Type Mismatch In Query Criteria????

Nov 4, 2006

Query1:

Src: Table1 joined Table2

ID (Type Text)
Title (Type Text)
Remarks(Type Text)
Formatted: FormatTitle([title],[Remarks])
Expr1: InStrRev([Formatted], "~")


public functionFormatTitle(ByVal sTitle as String, ByVal sRemarks as String) as String
'do process code here very complicated an long, but works find in the end
'creates a Multi-String delimited by | (pipe)
end function

The above works, and Expr1 does give an accurate value for the position of a "~" (tilde) in the string Created by the FormatTitle() function.

However, If I put a Criteria >0 on Expr1 it asks for the value of the [Formatted] field as if it was a parameter. If I put a criteria for Formatted: Like "*~*" I get a Data Type Mismatch in Query Criteria

Query2:
Src: Query1
Title (Type Text)
Remarks (Type Text)
Formatted(Type Text)
Exr1 (Type Number) criteria >0

This Query Also produces the Data Type Mismatch in Query Criteria
pardon me, but WTF? If it isn't a STring, than InStrRev() should produce an error, not an accurate response, and if InStrRev() produces a number why can't i compare it to 0 (zero)? This is indubitably messed up that I'm getting this error. There is no data type mismatch, on either of these tests, one is a string and I criteria-limit it by a string operation, the other is a number and I criteria limit it by a number, WHAT IS GOING ON!!!

Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner - The Frustratedly Confused

View 2 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







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