Code Error

May 1, 2005

I can't get this working. The code was posted by someone else. Anybody that can help, thanks so much.
........................
I have a table name main1.
I have a form name main2. (input box and command button)

..........................I placed the code into my command button......

Private Sub Command2_Click()
Set con = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.Recordset")
stSql = "SELECT * FROM main1 "
'I have the password stored in this table!

rs.Open stSql, con, 1 ' 1 = adOpenKeyset

If Not (rs.EOF) Then
If rs![PASSWORD] = Form_main2.Text1.Value Then
'Text1 is my unbound box for the user to enter the password!
DoCmd.OpenForm "intro"
DoCmd.OpenForm "main2"
DoCmd.Close
Else
MsgBox "You have entered the wrong Password!"
End If
End If
End Sub

View Replies


ADVERTISEMENT

General :: Disk Or Network Error With Error Code 3043

Jul 13, 2012

How I can get rid of Disk or network error with error code 3043? What this error indicates.

View 4 Replies View Related

Simple Error Trapping By Error Code

Dec 6, 2005

hi all

i have the following peice of code ...


Private Sub NextApplication_Click()
On Error GoTo Err_NextApplication_Click
DoCmd.GoToRecord , , acNext

Exit_NextApplication_Click:
Exit Sub

Err_NextApplication_Click:
If Err.Number = 2105 Then
MsgBox "Cannot navigate to the next record. This is the last record."
Else
MsgBox Err.Description
End If

Resume Exit_NextApplication_Click

End Sub


but even when this error occurs nothing is being properly handled the way i specified - any ideas ?

View 3 Replies View Related

No Error Code

Sep 27, 2005

While stepping through some Access VB statments at one point I come to a line which is;
Code: recordsetObject.Update

At this point, we leap off to the current error handler label.
However, on arrival err.number and such are blank.

How do I find the error generated by the errant rs.update ?

View 2 Replies View Related

Error Running Code

Sep 29, 2006

Hi,
I get this error when trying to rung a piece of code:
The expression On Load you entered as the event property setting produced the following error: Member already exists in an object module from which this object module derives.

I have the EXACT same code working on other forms using different fields and I just can't figure out why this particular one isn't working, it's driving me nuts!
My code is this:
Private Sub Form_Load()
Dim strReason As String

strReason2 = Nz(Ref3Poor_Reason, " ")

Select Case strReason3
Case "Not Known", "Unwilling to Give"
Poor1NavRef3.Visible = False
Poor2NavRef3.Visible = True

Case Else
Poor2NavRef3.Visible = False
Poor1NavRef3.Visible = True

End Select

Dim Ref3PoorCheck As Boolean
Ref3PoorCheck = Ref3Poor_Reference

Select Case Ref3PoorCheck

Case "True"
Ref3Poor_Reason.Visible = True

Case "False"
Ref3Poor_Reason.Visible = False

End Select

End Sub

Can anybody tell me where I'm going wrong please?
Thanks,
Dan

View 1 Replies View Related

Error In Code To Find Duplicates

Sep 29, 2005

Greetings all,

I have the code below which is giving me grief as I have copied it from a previous usage and it worked fine. I have tried it in a beforeupdate and now as a seperate button on the form and it gives me the same error message; I have tried to put a save command in to save the record without any luck

the code is

If DCount("[Batch]", "tbl_Data_Wine_Batch", "[Batch]=" & Me.Batch) > 0 Then
Cancel = True
End If


The error message is
Run time error 2001
you cancelled the previous operation.

The problem comes up in the dcount expression.

Any help would be great as it is an important part of the project and we can move on once we have overcome this

rbinder

View 1 Replies View Related

Error Message In Command Button Code

Jun 29, 2005

I have created command buttons to enter event registration information after biographical information has been completed. When I click on the button I get the following error message:

"Microsoft Office Access cannot find the field '|' referred to in your expression."

This is the On Click code that I have in there. Can anyone spot the error of my ways?

Private Sub RegisterButton_Click()
On Error GoTo Err_RegisterButton_Click
If IsNull(Me![AttendeeID]) Then
MsgBox "Enter attendee information before registering for an event."
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm "Registration", , , "[Registration]![RegistrationID]=Forms![Attendees]![Attendees Subform].form![RegistrationID]"
End If

Exit_RegisterButton_Click:
Exit Sub

Err_RegisterButton_Click:
MsgBox Err.Description
Resume Exit_RegisterButton_Click
End Sub

Thanks!

View 1 Replies View Related

Modules & VBA :: Code Runs OK Once But Error Next Time

Jun 26, 2015

The task is (1) output an Access query to Excel (2) overwrite that file if it already exists (3) apply specific formatting to the header row and the other rows in Excel. I have cobbled the code together from two sources. The beginning and end are adapted from code on btabdevelopment.com but the large insert in the middle is code I got form a project a former colleague had done. But he's no longer around.

The problem: I click the button and everything works OK. The file is created and formatted just how I want. If I click the button a second time though, it seems to run OK, but when I open the file it is NOT formatted. However, theres another window behind it called Book 1 which has all the data and all the correct formatting it just hasnt been saved. If I click it a third time I get an error message that says Object variable or With block variable not set. Im not even 100% all that is accurate because I have tried it a multitude of ways, closing and re-opening the form, closing and re-opening Access itself, starting with Excel open or closed, never with the destination excel file open though. I dont seem to get exactly the same behaviour any two times. But as far as I can see, if I close and re-open Access, it always works the first time. So I can live with it.

Code:
Private Sub cmdExport_Click()
On Error GoTo Errhandler
Dim rs As DAO.Recordset
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

[code]....

View 8 Replies View Related

General :: Combo Box Filter Error In Code

Sep 6, 2012

I am using a combo box to filter a 2nd form upon clicking a button. I posted on this topic the other month and was given some code that works. I am attempting to tweak it for another part of my database.I am receiving a Run-time error "3464': Data type mismatch in criteria expression.

DoCmd.OpenForm "Utilities Contacts", , , "[Utility] = """ & Me.Utility.Column(1) & """"
DoCmd.Close acForm, "Utility Menu"

View 4 Replies View Related

Quick Easy Question, RE Error With Simple Code

May 24, 2007

hiya every1, (access 2k3)

quick easy question, as im a noob when it comes to coding/vb.

Within our company database we have the usual timesheet table. With the table I have create a query (called "dailytimeforkeith") that gives me the sum of time for an individual person for one day (in fact its the previous day). What I have done then is created a form (called "keithyesterdaytime") that shows this query entry (called "sumoftimespent").

Each user has a different database screen logon and forms that are present when they log in. So what I then done is on one of these forms the load up, i attached this:

Private Sub Employee_Enter()

Me.Employee = User.FirstName


If Me.Employee = "Keith" Then

Dim stdocname As String

stdocname = "keithyesterdaytime"

DoCmd.OpenForm stdocname, , , acAdd

............



then on "keithyesterdaytime" opening the following code runs
------------------------------------------------------------

Private Sub Form_Open(Cancel As Integer)

Dim internal1 As Integer

internal1 = Forms!keithyesterdaytime.SumOfTimeSpent

If internal1 < 6 Then

DoCmd.Close

MsgBox " Less than 6 hours have been entered " & Chr(13) & " into your timesheet for yesterday. ", vbCritical, Title1

Else

DoCmd.Close

End If

End Sub
-------------------------------------------------------

Whenever i logon with the user keith, i get the following error 'runtime error 2427: You entered an expression that has no value.

If I open the form "keithyesterdaytime" on its own, the code works and i dont get an error.


What have i done wrong, and be gently. HEHEHE. Also is there any easy way i can do this instead of having to create the the form "keithyesterdaytime"

View 2 Replies View Related

General :: Code Error When Load Data From Server

Jun 5, 2014

Im using ms access 2010 and this program compatible with previously ms access.the error show is type mismatch (error 13) on

Code:

Set rbs = CurrentDb.OpenRecordset("SELECT MSysObjects.Name" _
& " FROM MSysObjects WHERE MSysObjects.Type= 1 And MSysObjects.Flags=0" _
& " and MSysObjects.Name='" & n_tb & "'")

View 2 Replies View Related

Modules & VBA :: Backup Code Getting Permission Denied Error

Aug 22, 2014

I got these three code routines for backing up an Access database file from two different forums. I installed them as is, on a test database, creating command buttons for each. The test database is not password protected. I intend (if I can get one of these working) to install it on simple, single file, password protected databases.The first two came from Access World Forums at: URL....

Code:

Function BACKUPS()
On Error GoTo Err_BACKUPS
Dim fso As Object
Dim sSourcePath As String
Dim sSourceFile As String
Dim sBackupPath As String
Dim sBackupFile As String

[code]....

I got a compile error "Invalid use of property." on the button sub. Then there was a simple On Click sub:

Code:

Private Sub Backup_Click()
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile CurrentProject.FullName, "C:", True
Set fs = Nothing
MsgBox "Database has been backed up successfully"
End Sub
Private Sub Command32_Click()
End Sub

On this one I got a "Permission denied." error on the CopyFile method. As I said before, my database is not password protected.I found this third bit of code on another forum: URL...

Code:
Public Function db_Backup()
On Error GoTo db_Backup_Err

Dim sourceFile As String, destinationFile As String
Dim aFSO As Variant
Dim path As String, name As String

[code]....

On this one I got another "Permission denied." error on the CopyFile method. Again, my database is not password protected. This code had appeared to me to be the most promising of the three.

View 14 Replies View Related

Forms :: Update And Save Button Code Is Getting Error

Aug 24, 2014

Quote:

Private Sub Save_Click()
If IsNull(cboEmpName) Then
MsgBox "Please Select Employee Name"
Me.cboEmpName.SetFocus
End If
If Me.txtNoofDaysWorked.Value = "0" Then
MsgBox "Please Enter No of Worked Days"

[code].....

View 1 Replies View Related

Modules & VBA :: Object Missing Error On Code To Apply Two Filters

May 12, 2015

I've got a form that takes the members from my members table and allows me to take attendance. I have it set up with toggle buttons in the footer (so we can see what class we're currently looking at) and I want to apply two filters when we click on a button. The two filters are "SS_Roll = Yes (or True)" and "SS_Class = AD1 (or whatever the class is)". I did some research and found one code for it, but now that I'm getting the missing object error and upon further research, I'm starting to think the code I found was only an excerpt. Below is the code I currently have. It highlights the first line when I hit debug.

Code:

Private Sub OptAD1_Click()
Table![MembersTable].FilterOn = True
Table![MembersTable].Filter = "[SS_Roll] = " & True And "[SS_Class] = " & AD1
End Sub

View 11 Replies View Related

Modules & VBA :: Calculate A Field That Excludes Weekends And Holidays - Code Error

Sep 24, 2014

I am using the function below to calculate a field that excludes weekends and holidays. The weekends are excluded as it is now, but when I try to add in code to exclude holidays I am getting errors. The code for the holidays is in bold and a couple of the errors are Loop without Do so I remove the Loop then I get a Else without If.

Code:
Option Compare Database

Public Function WorkingDays(Due_Date As Date, Result_Date As Date) As Integer
'-- Return the number of WorkingDays between Due_Date and Result_Date
On Error GoTo err_workingDays

[Code] ....

View 6 Replies View Related

Forms :: Multi Select Listbox Access 2003 Code Gives Syntax Error In MS Access 2010

Oct 24, 2013

I've been using the following code successfully in Access 2003 & now I need to migrate to Access 2010. The purpose of the code is to use the items that the user selects in the list box to build the criteria of a query. Access 2010 keeps giving me a syntax error when I try to run the query & I don't know why:

My code is:

On Error GoTo Err_Command151_Click

' Declare variables
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String

[Code] .....

The syntax error I get in Access 2010 is:

Syntax Error in query expression 'SELECT * FROM
qryContractListSummarybyDateContract3TYPEBREAK WHERE
qryContractListSummarybyDateContract3TYPEBREAK.Rep ortableName IN('Adbri
Masonry NSW');'

View 12 Replies View Related

Access 2007 Who Is Log On "code" Error Message

Dec 17, 2007

Not being a code person. This code worked great for 2003, but we just installed 2007. I get an error message when the this code runs:

Its a complie error
User-defined type not found

Sub ShowUserRosterMultipleUsers()
Dim cn As New ADODB.Connection.....red shows where I get the error message
Dim rs As New ADODB.Recordset
Dim i, j As Long

Set cn = CurrentProject.Connection

' The user roster is exposed as a provider-specific schema rowset
' in the Jet 4.0 OLE DB provider. You have to use a GUID to
' reference the schema, as provider-specific schemas are not
' listed in ADO's type library for schema rowsets

Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

'Output the list of all users in the current database.

Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
"", rs.Fields(2).Name, rs.Fields(3).Name

While Not rs.EOF
Debug.Print rs.Fields(0), rs.Fields(1), _
rs.Fields(2), rs.Fields(3)
rs.MoveNext
Wend

End Sub

View 7 Replies View Related

Please Review This Code, (simple Code) New With Codes

Feb 16, 2006

Works great, but when I hit the number "3", (3 times in row) it will let me into the form. I want it to not let me in IF I don't know the password.

Where did I go wrong?

Private Sub Form_Load()
Dim pw As Variant

If InputBox("What is the password?", "Password") = "1" Then
Else
MsgBox "Invalid Password", vbCritical, "Sorry Charlie"
DoCmd.Close
If InputBox("What is the password?", "Password") = "2" Then
Else
MsgBox "Invalid Password", vbCritical, "Sorry Charlie"
DoCmd.Close
End If
End If


End Sub

View 14 Replies View Related

Using Code To Unprotect And Protect Viewing Code

Jan 14, 2007

I protect my code from people being able to read it by setting a password on the code from Tools > Properties, selecting the Protection tab and entering a password, and clicking "Lock Project"

Is there a way to write code that will remove that Lock Project check and check it back on?

I've looked through the Application.SetOption command and it doesn't seem to be one of the choices. It would be very helpful if someone knew how to do this.

Thanks

SHADOW

View 6 Replies View Related

Microsoft JET Database Engine Error '80004005' Unspecified Error

Jan 28, 2004

Hi,

Im new to asp and access and have been having this problem for serveral weeks.

Every couple of days, all the asp pages on my site that communicate with the database start having 500 internal errors. i turned off the "Show friendly error messages" and one page gave me this specific error:

Microsoft JET Database Engine error '80004005'

Unspecified error

/admin/submitlogin.asp, line 8

I have tried a million things and have no idea why this is happening. Im not sure what other information i should post in order to see the problem. Any help would be greatly appreciated. Thank you,

Patrick

View 3 Replies View Related

Reserved Error (-1517); There Is No Message For This Error.

Mar 31, 2006

Does anybody know what this error message refers to?

"Reserved Error (-1517); there is no message for this error."

It just started happening today, and I haven't even made any changes to the database. It occurs when I hit a button I have to run a macro.

the macro does the following:
1) Shows all records
2) Requery
3) ApplyFilter.
The Where Condition for the filter is:
Right([tblContracts].[JobNum],4)=Right([Forms]![FrmContProc].[txtFindJobNum],4)

The weird thing is that it only occurs if the Form window is taller than 1/2 of my viewable area. If the Form window is 1/2 the viewable area or shorter, it works OK. This was running fine earlier today, but about 4:00 pm (03/31/06) this started happening.

If anybody knows what this error means, or how to get rid of it (I really need to use this window in full-screen) then please let me know.


-Thanks, Sean

View 10 Replies View Related

Error 3341 Or Error 3022; Do Or Don't, I'm Damned.

Aug 3, 2006

Okay, I'm kind of stumped here.I have a subform that has a button that sends a user to a "sibling" subform on another tab page, pass some information to ensure they are adding more details to the same records rather than creating two separate record.First time I programmed it, I got an error 3022 (keys cannot have duplicate values). I checked the query of the sibling subform and saw that the ID is from the one side table. I changed it so many table's foreign key is used. Second try, I got an error 3341 (there isn't a matching key in one side table).After some thinking, it also occured to me that I had set the query this way to allow addition of new record which wouldn't be possible if I had the query pulling the many side key, not the one side key.How do I get the subform to accept the ID that is being passed and create a new record using that ID?:confused:

View 5 Replies View Related

Modules & VBA :: Why On Error Is Skipping Next Error In Sequence

Sep 1, 2014

Code:

Private Sub Consolidate_Click()
Dim temp As Variant
Excel.Application.Visible = True
temp = Dir(CurrentProject.Path & "Inputs")
Do While temp <> vbNullString

[Code] ....

From the second iteration its not picking the error.

View 5 Replies View Related

Error Handling - Enough To Put In On Error Event

Sep 24, 2005

Every form has an on error property.

Is it enough for error handling to code the on error property for each form?
With enough I mean error handling which lets you resume the program.

Ontherwise I have to code (or call a procedure) for each coded event which i wouldn't prefer

For instance now I'm putting error handling in each event but would consider it more efficient if it can be placed once in each form
Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click

Dim stDocName As String

stDocName = "rptOfme"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdReport_Click:
Exit Sub

Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click

End Sub

View 3 Replies View Related

Error Message With No Error Number

Feb 1, 2006

Hello All,

I have been developing my database all one seems to be well exept for an error message which is attched.

If anybody can help me trap this error or offer some advice i would be greatfull.

Alastair

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







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