Modules & VBA :: Runtime Error 52 When Using Dir Function

Jul 2, 2013

I'm trying to delete a file in a network location. Sometimes the file is there, sometimes it's not, so I'm using the following code:

Code:
strPath = "
etwork driveMy Folder"
strFilename = "MyFile.doc"
If Not Dir(strPath & strFilename) = "" Then Kill strPath & strFilename

Occasionally, I get a runtime 52 error when the file doesn't exist. I don't understand why I'm getting this when, if the file doesn't exist, the Dir function should return "".I searched the forums for Runtime 52, and didn't find anything pertaining to this.

View Replies


ADVERTISEMENT

Modules & VBA :: INSERT INTO Runtime / Syntax Error?

Jun 11, 2013

Why I get a runtime 3134 error on this piece of code.

They are all text values

Code:

Dim strUserName As String
strUserName = Forms!FrmPrimaryData.FrmPrimaryDataInstallsSubFrm.Form.txtMacAddress
Dim strIDValue As String
strIDValue = Nz(DMax("[ID]", "radreply"), 0) + 1
Dim strAttribute As String

[Code] ....

View 6 Replies View Related

Modules & VBA :: RunTime Error 424 - Object Required

Aug 21, 2013

Basically I have a form where a user has selected a couple values from a dropdown element, and entered a few other text values into the form. I am then trying to grab the values and append them to a table.

Code:
Private Sub btnSubmitInputVendorPerformanceForm_Click() 'Button Is part of frmInputVendorPerformance
Dim ValueCheck As Integer 'Increments to make sure no errors in entry
Dim ErrorShow As String
Dim YesorNoAnswerToMessageBox As String
Dim QuestionToMessageBox As String
Dim DeliveryRate As String

[code]....

View 4 Replies View Related

Modules & VBA :: Find Record In A Subform / Getting A Runtime Error 438?

Feb 26, 2015

I have an unbound form: frm_ReceiptSearch with some fields that, when something is input, will search a datasheet viewed form on a subform on the main form (subform name is sf_frm_Receipts). Currently, on the txt_CheckNo field's after update event, I have the following code:

Private Sub txt_CheckNo_AfterUpdate()
Dim SrchVar As String
SrchVar = Me.txt_CheckNo
Me!sf_frm_Receipts!REFNO.SetFocus
DoCmd.FindRecord SrchVar, acEntire, , acSearchAll, , acCurrent, True
End Sub

but I'm getting a runtime error 438.

View 4 Replies View Related

Modules & VBA :: Runtime Error 3464 On Form Command Button

Jun 22, 2014

I am currently creating a form which includes a command button to update a field in a table to show Today's Date, at the time of running a query I am still yet to write.

I have the following code for my Command Button, which is returning the Runtime Error 3464 (Data type mismatch in Criteria Expression):

Private Sub cmdAddTodaysDate_Click()
CurrentDb.Execute (" UPDATE tblMyTable SET TodaysDate = " & Date & " WHERE tblMyTable.ProductCode = " & Me.txtProductCode)
End Sub

The query above seems to be having issues matching the text from the 'txtProductCode' textbox to the table field 'ProductCode'.

View 7 Replies View Related

Modules & VBA :: Runtime Error 2580 - Record Source Does Not Exist

Jun 9, 2015

I currently have this set as the forms default recordsource (which works just fine):

Code:
SELECT TOP 5 tblUsers_Phone_Book.EMAIL_ADDRESS, weightedDL('me@mine.com',[EMAIL_ADDRESS]) AS Expr1

And I have this vba to dynamically switch around that email address.

Code:
Private Sub Form_Load()
Dim intPos As Integer
Dim strControlName As String
Dim strValue As String
Dim sSQL As String
If Len(Me.OpenArgs) > 0 Then
' Position of the pipe

[Code] ....

If I msgbox the sSQL - it shows identical to the default recordsource but I get the error:

The error message I get is:

Run-Time error '2580'
The record source 'SELECT TOP 5 tblUsers_Phone_Book.EMAIL_ADDRESS, weightedDL('me@mine.com',[EMAIL_ADDRESS]) AS Expr1' specified on this form or report does not exist.

I tried copying the exact working default sql into the vba and get the same result.

View 3 Replies View Related

Modules & VBA :: Runtime Error 3464 - Data Type Mismatch

Mar 15, 2014

I have built in code a long sql statement as follows:

SELECT Age, BirdType, Flock, House, [Lab#], Organ, Origin, SampleDate, SampleType, Site, Source, SourceGroup,
[VT#], ProfileID, APIName1, APIAmts1, APILevels1, FullVals1, Match1, APIName2, APIAmts2, APILevels2,
FullVals2, Match2, APIName3, APIAmts3, APILevels3, FullVals3, Match3, APIName4, APIAmts4, APILevels4,
FullVals4, Match4, APIName5, APIAmts5, APILevels5, FullVals5, Match5, APIName6, APIAmts6, APILevels6,
FullVals6, Match6, APIName7, APIAmts7, APILevels7, FullVals7, Match7, APIName8, APIAmts8, APILevels8,

[Code] ......

When I try to open a recordset based on this sql, it gives me the runtime error - which is odd since I don't have any criteria in the statement.

I think the problem may be that vba is somehow adding a line break between "fullvals" and "18", but I don't know why it would do so and it doesn't always (only if the string is long).

View 9 Replies View Related

Modules & VBA :: Limit Down Report - Keep Getting Runtime Error 3075 Missing Operator

Feb 13, 2015

I have a report I am trying to limit down. I keep getting this error.

Code:

Run-time error '3075':
Syntax error (missing operator) in query expression ' and (Exercise = Barbell Squat)'.

Here is some of my code. What am I missing?

Dim whereCond As String
Forms!frmReports!cmdExercise.SetFocus
Exercise = Forms!frmReports!cmdExercise.Text
Forms!frmReports!cmdCategory.SetFocus
Category = Forms!frmReports!cmdCategory.Text

[Code] ....

View 3 Replies View Related

Modules & VBA :: Runtime Error 3071 When Used With IF Statement To Highlight Incorrect Entry

Jun 23, 2014

In my database I am trying to produce a "Statistics" function. As part of this, the user will enter a "Start Date" and "End Date" in a form and then click a button which will open the requested report with the date drawn from a query. The code on clicking the "All Jobs" button is:

Code:
DoCmd.OpenReport "RepStatisticsAllJobs", acViewPreview

Which works perfectly.

I am trying to stop the user from leaving the date fields blank or entering dates outside of the range of the database so I have tried the code:

Code:
Private Sub AllSalesEnquiries_Click()
If Me.DateFrom = "" Then
Beep
If MsgBox("You have not entered a start date", vbCritical, "Start Date Not Entered") Then

[Code] ....

If the user enters dates within the range of the database the report is presented correctly.

If the user does not enter a date or enters one outside of the range it produces the correct message box however if the user then corrects the mistake I receive a Runtime Error 3071 message. Clicking "Debug" highlights the final line of code:

DoCmd.OpenReport "RepStatisticsAllJobs", acViewPreview

I know that the code is correct because it works fine as stand alone code and it works if the user enters the correct dates so I am not sure where I am going wrong.

The date format works perfectly for the way dates are formatted in the database.

View 10 Replies View Related

Modules & VBA :: Sorting Out Data To Be Used In Final Table - Runtime Error 3021

Nov 25, 2014

I have managed to sort out the data to be used in the final table. However, I am having trouble transferring the data from each of their own tables into the final table.

Each time I run my code I receive "run-time error 3021: No current record."

It seems that only my timestamp is being added properly, but the error pops up and highlights the first "rstInsert.Edit" of my code. I'm suspecting that my function is running too fast, such that it did not have time to read that the table has already been populated by the timestamp in the AddNew code

Code:
Private Sub Command9_Click()
Dim dbs As DAO.Database
Dim rstTimestamp As DAO.Recordset
Dim rstAcknowledgement As DAO.Recordset
Dim rstAgent As DAO.Recordset

[Code] ....

View 1 Replies View Related

Modules & VBA :: Access 2010 / Runtime Error 1004 While Export To Excel

Jun 15, 2015

I'm using Access 2010 and I want to export a query to Excel by clicking a button. Every time I click on it Excel opens but doesn't open my worksheet, it's just gray like you just open the program without a table. After exiting it Access tells me I got a run time error 1004: the open-method of the workbook object couldn't be executed. After opening my Excel file it says that Excel found unreadable content and asks if I want to restore the content of the workbook.

Here is my code:

Code:
Private Sub Befehl62_Click()
Dim cdb As DAO.Database, qdf As DAO.QueryDef, SheetName As String, xlApp As Object
Set cdb = CurrentDb
Forms!Export_to_Excel!txtSheetName.SetFocus
SheetName = Me!txtSheetName.Text

[code]....

where my problem is?

View 14 Replies View Related

Modules & VBA :: Function Not Available In Expression Error

Sep 10, 2013

I have got a problem on one of our computers.

We use Microsoft Access databases to enter test data and eventually generate reports.

On 1 computers i get the following error when opening the report:

"Function is not available in expressions in query expression 'Left(.....)"

I figured this is a reference problem so the next thing i did was to pinpoint what reference was causing this error.

It turns out it is the Microsoft DAO 3.6 Object Library. Simply removing the reference and adding it again fixes it and allows you to open reports just fine.

The problem is though, this message comes back every now and then. Which is getting annoying and the person who is making the reports is about to throw his computer out of the window.

View 2 Replies View Related

Modules & VBA :: ConcatRelate Function - Error 3061 Too Few Parameters

Sep 18, 2014

I have been struggling with getting the syntax right for the ConcatRelate function. I have looked at other peoples examples and mine seems to have exactly the same syntax but it is giving me an error.

My Sql is

SELECT qr_RiverGroup.River, ConcatRelated("Site_ID","qr_RiverGroup","[River] = '" & [River] & "'") AS Expr1
FROM qr_RiverGroup;

View 7 Replies View Related

Modules & VBA :: Fix Type Mismatch Error With Dcount Function?

Dec 3, 2013

I ahve declared custCount as an integer and id as a string that comes from the user form (id = me.CustID) and trying to count the number of matching records in the recordset (rst) using the following:

custCount = DCount("[customerId]", rst, "[customerId] like '" & id & "'")

I'm getting a type mismatch error on the DCount statement?

View 3 Replies View Related

Modules & VBA :: Function To Get Fractions From Double - Error 91 With Custom Class

Jun 10, 2014

I haven't created classes in a while, and I don't see what is the problem

I'm modifying a function to get fractions from double. It worked well, but it returned a string.

I need it to be in parts, so I created this class

Code:
Option Compare Database
Public Entier As Integer
Public nominateur As Integer
Public denominateur As Integer
Public Function getText()
getText = Entier & " " & nominateur & "/" & denominateur
End Function

I changed the function type and the assignation:

Code:
Function GetFraction(ByVal Num As Double) As nombreEnFraction
Set GetFraction = New nombreEnFraction
If Num = 0# Then
GetFraction = "None"
Else
Dim WholeNumber As Integer
Dim DecimalNumber As Double

[Code] ....

For some reasons, when I get to the end of the function, I get a 91 error, like if it was nothing

But when I use a spy, I see values in the object until the end.

View 1 Replies View Related

Modules & VBA :: Type Mismatch Error On DMax Function Using Dates?

Oct 17, 2013

Anyway I've got a type mismatch that I can't figure out.

Code:
dMaxLstReq = DMax("reqNumb", "FlightLog", "Month([txtDate])='" & frmMonth & "'" And "Year([txtDate])='" & frmYear & "'")

In plain english: Select the highest value in the field named reqNumb from FlightLog where the Month of txtDate is equal to the variable frmMonth and the year of txtDate is equal to the variable frmYear.

txtDate is a Date/Time field in the table FlightLog

frmMonth and frmYear are both integer variables that take the system time (sysTime) and determine the month and year: I.E.

Code:
frmMonth = Month(sysTime) & frmYear = Year(sysTime)

Am I correct in thinking that the fact that my variables are integers and not times, that this is the cause of the mismatch?

View 2 Replies View Related

Modules & VBA :: Compile Error In Format Function - Cannot Find Project And Library

Nov 18, 2014

Code:
Private Sub Form_Open(Cancel As Integer)
cboDateStart.Value = Format(Now() - 7, "short date")
...
End Sub

When I run procedure the Format is highlighted and popup error message:

Compile error: Can't find project or library

View 1 Replies View Related

Modules & VBA :: Error (Invalid Use Of Null) In A Function Called From A Form Current Event

Nov 18, 2013

I am struggling trying to execute a function inside a Form_current event to display some stats.

The Function is this:

Code:
Function FlightsByAircraft(Aircraft As Long) As Long
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Dim str As String
str = "SELECT * FROM tblFlights WHERE AircraftID = " & Aircraft

[Code] ....

The code for the Form_Current event is this:

Private Sub Form_Current()
txtStats1 = FlightsByAircraft(Me.AircraftID)

Very simple. Well, the problem is when I move to a new record, a error message comes up: "Run-time error '94' - Invalid use of Null". It is because the AircraftID is not populated at that time. I tried to insert in the function code something like that:

Code:
If IsNull(Aircraft) then
exit function
else
.... (the DAO.Recordset code)

but it doesn't work.

View 8 Replies View Related

SQL ERROR - Runtime Error 3061 -

Aug 5, 2005

SQL Issue ...

ERROR: Runtime error 3061 - Too few parameters. Expected 1.

------------------------------------------------------------------------

Not sure how to work in the '* ROLL *' into this SQL statement. The query statement works fine ... I have tried different quotation methods ( Not Like " & " '
* ROLL * & ' " & " ) AND .... )

sql = "SELECT DISTINCTROW Sum(CDbl([Scrap Factor])) AS SumOFScrap FROM [RT: Signpro1: Costs] LEFT JOIN [DT: InventoryExtend] ON [RT: Signpro1: Costs].[Part Number] = [DT: InventoryExtend].[Part#] GROUP BY [DT: InventoryExtend].CategoryID, [DT: InventoryExtend].Description, [forms]![signpro sign estima parameters]![combo14] HAVING ((([DT: InventoryExtend].CategoryID)=30) AND (([DT: InventoryExtend].Description) Not Like '* ROLL *') AND (([forms]![signpro sign estima parameters]![combo14])=1));"

ANY HELP WOULD BE APPRECIATED ...

Cheers,
QTNM

View 14 Replies View Related

Function Called Via Auto-exec Fails When Using Access 2007 Runtime

Jan 8, 2013

I am making my very first tentative steps to convert my most complex Access 2003 app to run under Access 2007. There are no obvious problems when simply opening my original MDB file in Access 2007 or running it after conversion to an ACCDB file. However, when I try to run the ACCDB file under the Access 2007 Runtime I get a "You can't carry out this action at the present time..." error. This is then followed by the "Execution of this application has stopped due to a runtime error..."

To be more specific, I only get that error when I deliberately hide the back end database and thus invoke code triggered via Autoexec to allow the user to browse for the missing database. This code works fine when running under normal Access 2007 so it appears to be a Runtime issue.

View 3 Replies View Related

RunTime Error 75 - HELP !!!

Jul 30, 2005

Hi there,

I'm using the FILECOPY command to copy a specific file on the C drive to a CD.

I have been testing this for ages and it's been working fine. All of a sudden, I am getting a runtime 75 error. WHY???

Thanks in advance,
Paul.

View 1 Replies View Related

Runtime Error 429

Feb 13, 2007

Hi Everyone

Ive created a database using the file system object that creates folders, moves files from one folder to another, etc.

This works perfectly on my home pc, but when i try to install it on the server at work I get the following error message:-

Runtime Error 429

Active X component can't create object

I've had a look on the net and appears that it only happens on certain computers and I wondered if anyone had any quick fixes that they had come across over the years.

Thanks in anticipation

Kindest regards

Tony

View 2 Replies View Related

RunTime Error 0,20,91

Jun 15, 2007

Hi

I am getting Errors: 0,20,91 at the same subroutine
What could be the reason for the error?

Thanks

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

Runtime Error 3320

Jun 1, 2005

"Function is not available in expressions in table level validations"


I keep getting this message when trying to update the value of a text box when using the following code

Forms!frmFinanceProposal!Text940 = Me.Text253

Would someone be able to explain what this message means pls!!!

View 1 Replies View Related

Runtime Error 1004

Aug 31, 2005

Good morning

I had yesterday off work and have come back to a nightmare.

The database we use doesnt work the way it should anymore.

There is a switchboard which gives us the option to show a booking form...Worked fine until someone did something to it yesterday.

When I click on the command button to load the form I get an error saying that there was a runtime error 2001 " You canceled the previous operation"

How do I fix this??? I so confused.

I have tried opening the form other ways but it appears to be locked and wont open.


Please if someone could share some light!!!!


TIA

View 4 Replies View Related







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