Querydef Execute Error: Expected Function

Dec 9, 2005

All I want to do is run a make table query (or append) and show the user how many records were processed.
If I try to set recordset equal to the qdf.Execute I get the Compile error "Expected Function or variable".


I'm not sure what I'm missing...I've searched numerous threads and tried various combos of the execute method.

strquery = "qryEmailGenerate"
Set db = CurrentDb
Set qdf = db.QueryDefs(strquery)
Set rs = qdf.Execute
txtStatus = "Number of email recs: " & rs.RecordCount & vbCrLf

View Replies


ADVERTISEMENT

Error: Too Few Parameters. Expected 1

Feb 11, 2008

Hi All,I am getting problem "Error: too few parameters. Expected 1" when following Query is executed to updated a Flag Value in a table on Click event of a Submit button. CurrentDb.Execute "UPDATE Scheduled_Appointment SET Is_Taken = 1 WHERE Scheduled_Appointment_ID LIKE Me.Sch_P_ID"Where:Table: Scheduled_AppointmentColumn: Scheduled_Appointment_ID [Primary Key]Column: Is_Taken [ColumnType = Number ]Text Field: Me.Sch_P_ID [contains the Scheduled_Appointment_ID value for the selected Record on the Form]Thanks in Advance.

View 2 Replies View Related

Run-time Error '3061'- Expected 1

Jan 18, 2006

I have a error I need help with. Here is my code for my Global, and My Form Current: See the red for the Error Line, that show up in the VBE and the Blue is the code related to that line. I am using access 2003

'Declare all variables for right-side record counter
Dim bdg As DAO.Recordset
Dim swr As DAO.Recordset
Dim wtr As DAO.Recordset
Dim dmo As DAO.Recordset
''Dim dvt As DAO.Recordset
Dim occ As DAO.Recordset
Dim fre As DAO.Recordset
Dim swrlat As DAO.Recordset
Dim wrtlat As DAO.Recordset

Dim bdgCount As Integer
Dim swrcount As Integer
Dim wtrcount As Integer
Dim dmocount As Integer
Dim dvtcount As Integer
Dim occcount As Integer
Dim frecount As Integer
Dim countswr As Integer 'laterial counter
Dim countwtr As Integer 'laterial counter

Dim sqlbdg As String
Dim sqlswr As String
Dim sqlwtr As String
Dim sqldmo As String
''Dim sqldvt As String
Dim sqlocc As String
Dim sqlfre As String
Dim sqlswrlat As String
Dim sqlwtrlat As String

Dim db As DAO.Database


Private Sub Form_Current()
Set db = CurrentDb()
'Use SQL strings to pull data from the tables
sqlbdg = "SELECT [Building].[PIN] FROM Building WHERE [Building].[PIN]='" & Me![ADDRESS3] & "' ;"
sqlswr = "SELECT [Sewerform].[PIN] FROM [SEWER SERVICE LATERALS] WHERE [Sewerform].[PIN]='" & Me![ADDRESS3] & "' ;"
sqlwtr = "SELECT [water].[PIN] FROM [WATER SERVICE LATERALS] WHERE [water].[PIN]='" & Me![ADDRESS3] & "' ;"
sqlswrlat = "SELECT [SewerMain].[PIN] FROM [SEWER MAIN PRBLEMS] WHERE [SewerMain].[PIN]='" & Me![ADDRESS3] & "' ;"
sqlwtrlat = "SELECT [WaterMain].[PIN] FROM [WATER MAIN PROBLEMS] WHERE [WaterMain].[PIN]='" & Me![ADDRESS3] & "' ;"
sqldmo = "SELECT [Demolition Permits].[PID] FROM [Demolition Permits] WHERE [Demolition Permits].[PID]='" & Me![ADDRESS3] & "' ;"
''There is no PIN field in the development table ==> sqlwtr = "SELECT [Development Permits].[PIN] FROM [Development Permits] WHERE [Development Permits].[PIN]='" & Me![ADDRESS3] & "' ;"
sqlocc = "SELECT [Occupancy].[PIN] FROM Occupancy WHERE [Occupancy].[PIN]='" & Me![ADDRESS3] & "' ;"
sqlfre = "SELECT [Freeze].[PIN] FROM Freeze WHERE [FREEZE].[PIN]='" & Me![ADDRESS3] & "' ;"

Set bdg = db.OpenRecordset(sqlbdg, dbOpenSnapshot)
Set swr = db.OpenRecordset(sqlswr, dbOpenSnapshot)
Set wtr = db.OpenRecordset(sqlwtr, dbOpenSnapshot)
Set dmo = db.OpenRecordset(sqldmo, dbOpenSnapshot)
''Set dvt = db.OpenRecordset(sqldvt, dbOpenSnapshot)
Set occ = db.OpenRecordset(sqlocc, dbOpenSnapshot)
Set fre = db.OpenRecordset(sqlfre, dbOpenSnapshot)
Set swrlat = db.OpenRecordset(sqlswrlat, dbOpenSnapshot)
Set wrtlat = db.OpenRecordset(sqlwtrlat, dbOpenSnapshot)

'Building recordset
On Error Resume Next
If bdg.EOF And bdg.BOF = True Then
bdgCount = 0
Else

With bdg
.MoveFirst
.MoveLast
bdgCount = .RecordCount
End With

End If

'Sewer recordset
On Error Resume Next
If swr.EOF And swr.BOF = True Then
swrcount = 0
Else

With swr
.MoveFirst
.MoveLast
swrcount = .RecordCount
End With

End If

'Water recordset
On Error Resume Next
If wtr.EOF And wtr.BOF = True Then
wtrcount = 0
Else

With wtr
.MoveFirst
.MoveLast
wtrcount = .RecordCount
End With

End If
'Sewer laterial recordset
On Error Resume Next
If swrlat.EOF And swrlat.BOF = True Then
countswr = 0
Else

With swrlat
.MoveFirst
.MoveLast
countswr = .RecordCount
End With

End If

'Water laterial recordset
On Error Resume Next
If wrtlat.EOF And wrtlat.BOF = True Then
countwtr = 0
Else

With wrtlat
.MoveFirst
.MoveLast
countwtr = .RecordCount
End With

End If

'Demolition recordset
On Error Resume Next
If dmo.EOF And dmo.BOF = True Then
dmocount = 0
Else

With dmo
.MoveFirst
.MoveLast
dmocount = .RecordCount
End With

End If

'Development recordset
''On Error Resume Next
''If dvt.EOF And dvt.BOF = True Then
dvtcount = 0
''Else

''With dvt
'' .MoveFirst
'' .MoveLast
'' dvtcount = .RecordCount
''End With

''End If

'Occupancy recordset
On Error Resume Next
If occ.EOF And occ.BOF = True Then
occcount = 0
Else

With occ
.MoveFirst
.MoveLast
occcount = .RecordCount
End With

End If

'Freeze recordset
On Error Resume Next
If fre.EOF And fre.BOF = True Then
frecount = 0
Else

With fre
.MoveFirst
.MoveLast
frecount = .RecordCount
End With

End If

'Set the values of the recordcounts to the appropriate text boxes

txtbdgcount.SetFocus
txtbdgcount.Text = bdgCount
txtswrcount.SetFocus
txtswrcount.Text = swrcount
txtwtrcount.SetFocus
txtwtrcount.Text = wtrcount
txtdmocount.SetFocus
txtdmocount.Text = dmocount
txtdvtcount.SetFocus
txtdvtcount.Text = dvtcount
txtocccount.SetFocus
txtocccount.Text = occcount
txtfrecount.SetFocus
txtfrecount.Text = frecount
txtcountswr.SetFocus
txtcountswr.Text = countswr
txtcountwtr.SetFocus
txtcountwtr.Text = countwtr


PARID.SetFocus


' Provide a record counter for using with
' custom navigation buttons (when not using
' Access built in navigation)

Dim rst As DAO.Recordset
Dim lngCount As Long

Set rst = Me.RecordsetClone

With rst
.MoveFirst
.MoveLast
lngCount = .RecordCount
End With

'Show the result of the record count in the text box (txtRecordNo)

Me.Text34 = "Record " & Me.CurrentRecord & " of " & lngCount
End Sub

View 6 Replies View Related

Error 3061; Too Few Parameters. Expected 2

Jun 15, 2005

I am running this code, and i am getting this error:


Code:Private Sub SendFormToConsultants_Click() On Error GoTo Err_SendFormToConsultants_Click Dim stWhere As String '-- Criteria for DLookup Dim varTo As Variant '-- Address for SendObject Dim stText As String '-- E-mail text Dim stSubject As String '-- Subject line of e-mail Dim stCOFNumber As String '-- The COF Number from form Dim stCustomerID As String '-- The Customer ID from form Dim stCompanyName As String '-- The Company Name from form Dim stContactName As String '-- The Contact Name from form Dim stAddress As String '-- The Company Address from form Dim stTRDW As String '-- The TRDW from form Dim stPreReq As String '-- The PreReq from form Dim stWorkLoc As String '-- The Location of Work from form Dim stDelivActiv As String '-- The Deliverables/Activities from form Dim stStartDate As Date '-- The Start Date from Subform Dim stEndDate As Date '-- The End Date from Subform Dim stWho As String '-- Reference to Resources Dim strSQL As String '-- Create SQL update statement Dim errLoop As Error '-- Combo of names to assign COF to stWho = Me.COF_Scheduled__Assigned_Resources__Subform1!Res ourceName stWhere = "Resources.ResourceName = " & "'" & stWho & "'" '-- Looks up email address from Resources varTo = DLookup("[ResourceEmail]", "Resources", stWhere) stCOFNumber = Me!COFNumber stCustomerID = Me.Consultancy_Order_Form_CustomerID stCompanyName = Me.CompanyName stContactName = Me!COFContact stAddress = Me.Address stTRDW = Me.TRDW stPreReq = Me.PreRequisites stWorkLoc = Me.WorkLocation stDelivActiv = Me.DeliverablesActivities stStartDate = Me.COF_Scheduled__Assigned_Resources__Subform1!Sta rtDate stEndDate = Me.COF_Scheduled__Assigned_Resources__Subform1!End Date stSubject = ":: New Consultancy Order Assigned ::" stText = "You have been assigned a new Consultancy Order." & vbCrLf & _ "Consultancy Order Form Number: " & stCOFNumber & _ vbCrLf & _ "Company ID: " & stCustomerID & _ vbCrLf & _ "Company Name: " & stCompanyName & _ vbCrLf & _ "Contact Name: " & stContactName & _ vbCrLf & _ "Address: " & stAddress & _ vbCrLf & _ "Terms of Reference / Description of Work: " & stTRDW & _ vbCrLf & _ "Pre-Requisites: " & stPreReq & _ vbCrLf & _ "Location of Work: " & stWorkLoc & _ vbCrLf & _ "Deliverables / Activities: " & stDelivActiv & _ vbCrLf & _ "Start Date: " & stStartDate & _ vbCrLf & _ "End Date: " & stEndDate & _ vbCrLf & _ "Please reply to confirm Consultancy Order Assignment." 'Write the e-mail content for sending to Consultant DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1 'Set the update statement to disable command button once e-mail is sent strSQL = "UPDATE [Consultancy Order Form] SET [Consultancy Order Form].COFSentToConsultants = 0 " & _ "Where [Consultancy Order Form].COFNumber = " & Me!COFNumber & ";" On Error GoTo Err_Execute CurrentDb.Execute strSQL, dbFailOnError On Error GoTo 0 'Requery checkbox to show checked 'after update statement has ran 'and disable send mail command button Me!COFSentToConsultants.Requery Me!COFSentToConsultants.SetFocus Me.SendFormToConsultants.Enabled = False Exit SubErr_Execute: ' Notify user of any errors that result from ' executing the query. If DBEngine.Errors.Count > 0 Then For Each errLoop In DBEngine.Errors MsgBox "Error number: " & errLoop.Number & vbCr & _ errLoop.Description Next errLoop End If Resume NextExit_SendFormToConsultants_Click: Exit SubErr_SendFormToConsultants_Click: MsgBox Err.Description Resume Exit_SendFormToConsultants_ClickEnd Sub

What does it mean? it doesn't say where i have a problem in my code. What do you think?

View 3 Replies View Related

Queries :: Execute Query That Doesn't Include Specified Expression As Aggregated Function

Mar 21, 2013

I am receiving this error when i try to run a query:

"You tried to execute a query that doesn't include specified expression as an aggregated function"

There are two images attached which show the SQL view, the error and the design view.

View 11 Replies View Related

Modules & VBA :: Error 3274 - External Table Is Not In Expected Format

Apr 2, 2014

I have a function that exports a number of tables within an access 2007 database to one spreadsheet using docmd.transferspreadsheet.

The error message in the title of this post presents itself during a loop which transfers the tables to the spreadsheet. However, it doesn't always happen, sometimes it completes the process perfectly which is quite frustrating.

Below is the section of code where the error occurs ....

Set rs = CurrentDb.OpenRecordset("SELECT * FROM tbl_Table_Exports WHERE Type = 'CRM'", dbOpenSnapshot)
rs.MoveFirst
Do Until rs.EOF
TableName = rs.Fields("Table")
WSName = rs.Fields("WSName")
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, TableName, NewWBPath, True, WSName
rs.MoveNext
Loop

View 1 Replies View Related

Modules & VBA :: Access 2003 - Compile Error Expected / End Of Statement

Apr 19, 2014

I'm using MS Access 2003 and having difficulty with VBA.

Code:
strSql = "Insert into TBLCONDUTOR (Codigo, pretensao, ncarta, nlicenca, nome, apelido, dnascimento, contacto1, contacto2, email, nbicc, nnif, morada, localidade, cidade, cpostal, _
imagemcondutor, catAM, dataemissaoAM, datavalidadeAM, catA1, dataemissaoA1, datavalidadeA1, catA2, dataemissaoA2, datavalidadeA2, catA, dataemissaoA, datavalidadeA, _
catB1, dataemissaoB1, datavalidadeB1, catB, dataemissaoB, datavalidadeB, catBE, dataemissaoBE, datavalidadeBE,

[Code] ....

View 3 Replies View Related

Error Message Cannot Execute Command

Mar 3, 2006

I got the error message cannot execute command after we upgraded from Access 97 to Access 2000. There are multiple users connected to one database on Windows 2000. Some people are able to get access, but there is a good chunk of people that get the error message " Cannot execute Command".

What's going on and is there a solution?

View 3 Replies View Related

Error: You Tried To Execute A Query That Does Not Include The Specific Expression

Feb 28, 2008

I have a combobox iBrand on a form frmFoodSub with the following query used to get its values (based on the imput of another combobox, iProduct, linked to the field Product in the table Products.) This code was generated by query builder, not myself:

Code:SELECT Products.BrandFROM ProductsWHERE (((Products.Product)=[Me]![frmFoodSub].[form].[iProduct]))GROUP BY Products.BrandORDER BY Products.Product;

And I keep getting this error message when the combobox is in focus on my form:

You tried to execute a query that does not include the specific expression 'Products.Product' as part of the aggregated function.

I have no idea what started this error. It was all working fine and then all of a sudden the error started appearing and I can't remember making any changes to cause it.

View 2 Replies View Related

Modules & VBA :: Update And Amend Records In A Table - Error Trying To Execute SQL Statement

Jun 18, 2013

I'm trying to create a function to update and amend records in a table.

The update part works and updates existing records with new data but I'm getting an error with the insert part.

Run time error 3078
The Microsoft Office Access database engine cannot find the input table or query 'FALSE'. Make sure it exists and that its name is spelled correctly.

Nothing called 'FALSE' so not sure what that means?

Code:

sSQL = "INSERT INTO Pupil_tb (PupilID,Class,PupilName,etc ) " _
= "SELECT PupilImport_tb.PupilID, Class, PupilName, etc FROM PupilImport_tb " _
& "LEFT JOIN Pupil_tb " _
& "ON Pupil_tb.PupilID=PupilImport_tb.PupilID " _
& "WHERE Pupil_tb.PupilID Is Null "

CurrentDb.Execute sSQL, dbFailOnError

View 5 Replies View Related

Forms :: SUM Function Produces Error From Calculated Function

Jan 30, 2014

I have a project at hand and it's been a predecessor of mine and client has asked me to do some work on it and extend functionality - but I have not really delved into Access before and I have had to worked my way through to this final snag :/

The Main Form has one sub form. This sub form allows the user to add multiple order items i.e. qty, stock, description from records within the system - fairly straight forward.At the last column of each row is the sub total of those particular items i.e.

Qty Unit | Item ID | Total
-----------------------
2 | 1234 | 80.00
------------------------
1 | 43526 | 20.00
------------------------
> | |

So the total is a function of =[Qty Unit] * [Unit Price].Then in the Footer of this SubForm is the Sub Total

=SUM([Qty Unit] * [Unit Price])

All fine and well..... However, the additional functionality kicks in.

Lets add the additional customer_id from the Main Form. Each Item bought is dependent on the customer_id i.e. they get special prices depending on who they are.So a New table is made which has the Item ID and SpecialPriceID (of a table to define as a specialPrice) and the Price linked to this Item and Special Price category. So say that there are two groups of users "wholesale" and "nonwholesale" these would be SP_1 and SP_2 and each client is defined either one of these, and each stock item has a Price for each SP_1 and SP_2. Hopefully I've explained myself there.

Back to the SubForm. So now the Total needs to calculated differently with needed the external customer_id from the Main Form.

Code:

Function CalculateSpecialPrice(ItemID As String, CustomerID As String, Unit As Integer)
Dim SPSelect As String
SPSelect = "SELECT Price FROM [Items_SpecialPrices] WHERE"
SPSelect = SPSelect & " ItemID = '" & ItemID
SPSelect = SPSelect & "' AND SpecialPriceID = (SELECT SpecialPriceID FROM Customers WHERE customer_id = " & CustomerID & ") "

[code]....

its the sub total I just keep on getting #Error on. I have even watched (using alerts) that the correct return variable is the same as the individual rows. This is the equation I used for the SubTotal within the footer.

=SUM(CalculateSpecialPrice([Item ID], [Form]![FormName]![CustomerID], [Qty Unit]))
#Error

View 2 Replies View Related

QueryDef What Is It

May 10, 2005

why wont my DB reconise this script

View 3 Replies View Related

QueryDef Type=3?

Sep 30, 2005

Does anyone know what a QueryDef Type of 3 is?

If I run the following code, as well as returning all queries in the db, it also returns a few that are of Type=3.


For Each qd In db.QueryDefs
Debug.Print qd.Name & " - " & qd.Type
Next

For the Type 3 ones, the qd.Name returns something like

~sq_rREPORTNAME
where REPORTNAME is the name of a report in the database .

However, it's only a couple of reports that appear this way.


Where or what is a Type 3 - even if I view Hidden & System objects I can't see them!

View 1 Replies View Related

QueryDEF One More Time!

Sep 26, 2005

Hello everybody,

I'm looking for solution to this. I've already searched in this forum a lot of healines for this problem but none of them really helps me.

I know that We're not suposed to change static Querys and bla bla bla because they static and bla bla bla bla BUT....
the thing is...

I have this form with a lot of filters for a report. I Want to change the join fields and parameters according to what the user chose in the form and then run the report.

The Report Record source property needs to be populated with a query object.
to do that I need to some how load the query and change its sql.


Dim Q as QueryDef
set q = CurrentDB.QueryDef("MYQUERY")

I don't know what property I can use, MS HELP doesn't help actually
when I type "Q." after the dot the list of properties doesn't show.

Thank you !

View 1 Replies View Related

Queries :: Reference QueryDef Name From SQL It Contains?

Aug 3, 2013

Is there a way for a SQL QueryDef object in Access to look up the name of itself in the SQL and return that as a value in the result set? Ex:

Code:
SELECT [foo],
[bar],
[something]
@NameOfQueryDef
FROM [table]

View 3 Replies View Related

Modules & VBA :: Add WHERE Clause To Query (queryDef)

Dec 1, 2014

I have a TRANSFORMED query:

Code:
TRANSFORM nz(count(T_qa.qaQAPK),0) AS SumOfQAs
SELECT month(qaDate) AS QAmonth, Count(T_qa.qaQAPK) AS QAs
FROM Q_ALL_qa
GROUP BY Month(qaDate)
PIVOT month([qaDate])
IN (1,2,3,4,5,6,7,8,9,10,11,12);

This query is record source for a report, then this report show all calculations in a form.

I have 7 of each (query + report) all showing on the same form.

All those queries calculate data for all departments.

In the form, I have placed a combobox.

What I want is to create a vba code which will add clause WHERE to all queries at the same time and then run it.

Code:
WHERE qaDeptFK=Forms!F_CompLvl.cboDeptStats

However, if nothing has been selected in the combo, I want the queries to calculate data as normal, for all departments.

Where do I place the vba statement? Is it under combobox AfterUpdate event?

I am planning to use this: (As I never done it before)
[URL] ....
Modifying SQL On-The-Fly section

View 5 Replies View Related

Modules & VBA :: QueryDef And Export To Excel

Jun 13, 2014

So I had this code working and then I cleaned it up a little and it no longer works. It should export data from a created query using criteria selected by the user on a form and put it into an excel file that exists. I get no errors but it does not export anymore. After pouring over it for a while checking for mistakes with my form control references and variables I have yet to find anything. I did change my form name and edited the code accordingly after I already had it working, and changed a few form settings but changing them back did not fix the issue. I am not very experienced and stumped since I am not getting error messages.

Code:

'First set variables for the SQL string and CreateQueryDef command
Dim strExport As String
Dim qdf As dao.QueryDef
'Then define the SQL to be exported (Static Response Info by ItemID)

[Code] ......

View 6 Replies View Related

Modules & VBA :: Filtering Form / Report - QueryDef Criteria Using OR

May 7, 2015

I have a form with 3 combo boxes that filter another form/report. The first combo (cboByCategory) contains options from 2 different fields within the same table. Before I added this add'l piece of code, all 3 combos worked fine. I am not getting error messages, it just does not filter on the other 2 combo boxes - cboDiv and cboGender.

Code:
Private Sub cmdModifyRecords_Click()
On Error GoTo Err_cmdModifyRecords_Click
Dim stDocName As String
Dim strFilter As String
Dim stLinkCriteria As String
stDocName = "Modify_OpenItems"

[Code] .....

View 5 Replies View Related

Modules & VBA :: Finding Last Record (QueryDef Or Recordset Method)

Feb 11, 2014

My question is which method of finding the last record is best, QueryDef or Recordset? Here is my data:

Table:
tbl_module_repairs

Field:
aps_rma

Textbox to insert last record RMA into:
txt_test

Here is some code I tried but get an invalid argument msgbox:

'''''''''''''''''''''''''''''''''
'Opens last RMA into textbox (For opening tag sheet)
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
'Get the database and Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tbl_module_repairs")

[Code] .....

View 14 Replies View Related

Modules & VBA :: Edit Recordset Querydef That Has Calculated Field

Jan 19, 2014

Is it possible to add/edit a record from a DAO querydef that has a calculated field in.

Code:

Set qdf = db.QueryDefs("qryOutput_" & strDept)
qdf.Parameters("Enter Date") = dDate
Set rs = qdf.OpenRecordset()

Using the rs.Edit or rs.AddNew worked fine until I put a calculated field in the query.

The calculated field is just a total of some fields in the table.

I thought this was something to do with dbOpenDynaset but it just keeps having the same error

Cannot update. Database or object is read-only.

View 3 Replies View Related

Modules & VBA :: Query To Search For Records - Passing Parameters In A QueryDef

Aug 27, 2013

I have a query that searches for records that are between two dates using the WHERE clause. The two dates are referenced to two respective text boxes on a form. On the same form I have a button that will launch the query in VBA using querydefs. I get the error 3061 saying I need to input the parameters. Therefore I am a bit unsure how to set the parameters in VBA. So far I have done this:

Code:

Dim Db As DAO.Database
Set Db = CurrentDb
Dim QDef As DAO.QueryDef
Dim rst As DAO.Recordset
Set QDef = Db.QueryDefs("Rqt_F_BrokerageMandate_MF3_TEST")

[Code] ....

Where Date_VL is the field to be filtered. I know this is wrong but all examples I have seen have equated the parameter to a fixed value i.e 30/12/2012 for example, but I want this to be at the users discression. The only way I know of to get around this at the moment would be to write a temp query in VBA with PARAMETERS in the SQL code instead using the method above/

After this I'm going to assign the recordset to a matrix but that's a different story!

View 10 Replies View Related

Error Msg - On SUM Function??

Dec 21, 2004

why am i receiving the followign error:
"Sub of function not defined"

on the following statement:

me.txtTotal = Sum(lstbox.Column(7))

I'm so stumped.. this is a built-in function, no?

Thanks!

- Jenn

View 1 Replies View Related

WHY Am I Getting This Error? (Date Function)

Aug 12, 2005

I don't get it!!!! I use it all the time. <=Date() should get all rows with no future dates...but I get this error on some of my queries...I've never got this error before... :mad: :mad: :mad: :mad:

Sorry about the poor image quality.

View 1 Replies View Related

Error With Trim Function

Nov 1, 2005

I have used the Trim function in a query and am getting an error. At first I was concatanating several fields but have cut it back to the most basic form but still receive the error. The error says that the trim expression failed. Here is the code I used:

fullname: trim([last]) + ", " + trim([first]) + " " + trim([middle])

I then used
fullname: trim([last])

I got the same error. Just using the field last does not generate an error.

Any ideas? I created the DB in Access XP and am getting the error in 2003. I tried the changes in 2003 but still got the error.

thanks. :)

View 3 Replies View Related

If Function To Remove Error

Oct 29, 2006

Hi - I am using the replace function in a query expression to remove spaces in a postcode field:Replace([POSTCODE]," ","")) However, this returns an error if the Postcode is left blank - as I am trying to match the postcodes from 2 queries the error is giving a type mismatch.(I presume its this anyway)I am thinking I need to use an Iff function deal with the instance of no postcode(i.e. NULL) but I can't get it to work.IIf([POSTCODE]=NULL,"No Code",Replace([POSTCODE]," ",""))Would be grateful if anyone could help me out.ThanksRuss

View 5 Replies View Related

#Error With Function In Query

Nov 11, 2006

Hi All,

I made a function to calculate the difference in hours between two times.

Function TimeDiff(Time1 As String, Time2 As String) As Double
'This function is used to calculate the difference in hours between two times.
'It is capable of handling a finish time that is after midnight.

TimeDiff = 0

If Not IsNull(Time1) And Not IsNull(Time2) Then

If CDate(Time1) > CDate(Time2) Then
TimeDiff = ((CDate(Time2) - CDate(Time1)) + 1) * 24
Else
TimeDiff = (CDate(Time2) - CDate(Time1)) * 24
End If

End If

End Function
I have a query where there are 2 sets of times in fields (Start1, Finish1, Start2, Finish2).
When I add a calculated column with the following expression:
Expr1: TimeDiff(Start1,Finish1) + TimeDiff(Start2,Finish2)
it calculates in the query correctly.

However, when I made a new function that incorporated this function, it gave me the #error result in the calculated field.
Function OrdinaryHours(Status As String, Start1 As String, Finish1 As String, Optional Start2 As String, Optional Finish2 As String) As Double

'Initialise
OrdinaryHours = 0

'If employee is NOT a casual
If Not Status = "CT" Then

If Not IsMissing(Start2) And Not IsMissing(Finish2) Then
OrdinaryHours = TimeDiff(Start1, Finish1) + TimeDiff(Start2, Finish2)
Else
OrdinaryHours = TimeDiff(Start1, Finish1)
End If

End If


End Function
Does anyone know why this would #Error. I have the TimeDiff function initialising to = 0 before doing anything...I am stumped why it returns #Error when it should return 0 in the case of something going wrong.

Brad

View 5 Replies View Related







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