Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / June 2006

Tip: Looking for answers? Try searching our database.

Update Query Crashes Access -- why?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Al - 30 Jun 2006 04:18 GMT
I am using MS Access 2003.  My application has a form with a command button
on it that will "lock" a record from further updating--turns a bit variable
on.  Below  are the command button basics:

Private Sub cmdLockCustomer_Click()
On Error GoTo Err_Handler

   Dim strCustCode As String
   
   strCustCode = Me.txtCustomerCode

   Call LockCustomer(strCustCode)

Exit_Here:
   Exit Sub
Err_Handler:
   LogErrorToTable Err.Number, Err.Description, "Form_CustomerInfo",
"LockCustomer", Erl
   Resume Exit_Here
   
End Sub

Public Function LockCustomer(CustCode As String)

   On Error GoTo Err_Handler
   
   Dim strSQL As String
   Dim dbs As DAO.Database
       
   Set dbs = CurrentDb
   
   
   strSQL = "UPDATE CustomerInfo SET [Locked] = True WHERE
([CustomerCode]='" & CustCode & "');"
   dbs.Execute strSQL, dbSeeChanges + dbFailOnError
   
Exit_Here:
   Set dbs = Nothing
   Exit Function
Err_Handler:
   LogErrorToTable Err.Number, Err.Description, "CustomerServices",
"LockCustomer", Erl
   Resume Exit_Here
   
End Function

When the dbs.execute statement runs it crashes access and totally blows me
out.  Anyone know why this might happen?

Here is the Access error msg:

AppName: msaccess.exe      AppVer: 11.0.6566.0     AppStamp:42cdb33e
ModName: ntdll.dll      ModVer: 5.1.2600.2180      ModStamp:411096b4
fDebug: 0       Offset: 00001010

Thanks for your help!!
AccessVandal - 30 Jun 2006 11:01 GMT
I suggest you rename the column “Locked” and the control in the form as well.

“Locked” is a reserved name for Access.

‘strSQL = "UPDATE CustomerInfo SET [Locked] = True WHERE
‘([CustomerCode]='" & CustCode & "');"
‘    dbs.Execute strSQL, dbSeeChanges + dbFailOnError

Try something like ,

UPDATE CustomerInfo SET YourColumnName = -1

If the Data Type is “Yes/No” in your table.

-1 = True 0 = False
if you are using a checkbox on a form.
Al - 30 Jun 2006 15:04 GMT
Thanks AccessVandal.

I tested this SQL in a query before I put it in code and it ran well with
the "Locked" variable name.  I believe by putting brackets around locked it
turns it into a field name.  I used your variable substitution idea of -1,0
for true, false.  I do like that better.

Lastly I figured out that the SQL option dbFailOnError was causing the
error.  I eliminated that out of the sql statement and it seems to work fine
now.

Thanks again!

> I suggest you rename the column “Locked” and the control in the form as well.
>
[quoted text clipped - 12 lines]
> -1 = True 0 = False
> if you are using a checkbox on a form.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.