Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 02-06-2004, 02:03 AM   #1
andrewf10
Registered User
 
andrewf10's Avatar
 
Join Date: Mar 2003
Location: Ireland
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
andrewf10
Run time error 13

Hi folks,

I have 2 forms on a table. Record locking is set to 'edited record'.

User 2 goes onto Form 2 and edits record. User 1 goes onto Form 1 and presses 'save' for whatever reason.

The save button attempts to set a field (say field1) to some value but gives a run time error 13 'type mismatch'.


If the opposite is done in that form 1 is being edited and form 2 is saved (same field1 is changed), a different run time error occurs (2448) which is the one I'd expect in a user locking situation.

The only difference between the forms is that Form1 allows records to be created and Form2 only allows them to be edited.

Is this normal? Is there a way around it?

Any help to solving this annoying problem would be greatly appreciated

__________________
I'm using Access 2000 on Windows 95/98/2000/XP
andrewf10 is offline   Reply With Quote
Old 02-06-2004, 03:13 AM   #2
Mile-O
Back once again...
 
Mile-O's Avatar
 
Join Date: Dec 2002
Location: Glasgow, UK
Posts: 11,312
Thanks: 4
Thanked 117 Times in 107 Posts
Mile-O will become famous soon enough
Re: Run time error 13

Quote:
Originally posted by andrewf10
The save button attempts to set a field (say field1) to some value but gives a run time error 13 'type mismatch'
You are trying to assign a value to a field that it can't accept i.e. putting some text into a numeric field.
Mile-O is offline   Reply With Quote
Old 02-06-2004, 03:37 AM   #3
andrewf10
Registered User
 
andrewf10's Avatar
 
Join Date: Mar 2003
Location: Ireland
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
andrewf10
But all fields are textboxes. And the exact same code works on the other form...

__________________
I'm using Access 2000 on Windows 95/98/2000/XP
andrewf10 is offline   Reply With Quote
Old 02-06-2004, 03:46 AM   #4
Mile-O
Back once again...
 
Mile-O's Avatar
 
Join Date: Dec 2002
Location: Glasgow, UK
Posts: 11,312
Thanks: 4
Thanked 117 Times in 107 Posts
Mile-O will become famous soon enough
Okay, cut the generics (i.e. user1 and form2, etc.) - be specific.

Don't call a textbox a field - it's a textbox. A field is what it's bound to. There's a difference.
Mile-O is offline   Reply With Quote
Old 02-06-2004, 04:14 AM   #5
andrewf10
Registered User
 
andrewf10's Avatar
 
Join Date: Mar 2003
Location: Ireland
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
andrewf10
Apologies.

I've attached (if the filters in work allow me to) the database below. You need to use the User Level Security Wizard to create an additional user and group.

Then log on, open "frmCollateralPur" and edit the 'Description' textbox before logging on as a second user and opening "frmCollateralNPD" and hit save.

Note how if done in opposite directions, 2 different run time errors occur.

Thanks
Attached Files
File Type: zip test1.zip (27.6 KB, 86 views)
__________________
I'm using Access 2000 on Windows 95/98/2000/XP
andrewf10 is offline   Reply With Quote
Old 02-06-2004, 04:38 AM   #6
Mile-O
Back once again...
 
Mile-O's Avatar
 
Join Date: Dec 2002
Location: Glasgow, UK
Posts: 11,312
Thanks: 4
Thanked 117 Times in 107 Posts
Mile-O will become famous soon enough
Quote:
Originally posted by andrewf10
You need to use the User Level Security
Urgh! Sorry, you've hit my bete noire of Access. I can't help on that. I still maintain, however, that a field is not receiving the correct value.
Mile-O is offline   Reply With Quote
Old 02-06-2004, 04:46 AM   #7
andrewf10
Registered User
 
andrewf10's Avatar
 
Join Date: Mar 2003
Location: Ireland
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
andrewf10
Its tough alright!

As you've probably seen, it retrieves the network username through the module without a problem, it concatenates perfectly but it's just that last part where it attempts to write to the textbox, and only ever on the form where records are created, that it plays up. I'll continue my investigations...

__________________
I'm using Access 2000 on Windows 95/98/2000/XP
andrewf10 is offline   Reply With Quote
Old 02-08-2004, 06:03 AM   #8
andrewf10
Registered User
 
andrewf10's Avatar
 
Join Date: Mar 2003
Location: Ireland
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
andrewf10
Do the experts among you think it would be bad practice to trap error number 13 with a record-locking message considering that the VB Help gives 6 other possible causes?
__________________
I'm using Access 2000 on Windows 95/98/2000/XP
andrewf10 is offline   Reply With Quote
Old 02-10-2004, 01:35 AM   #9
andrewf10
Registered User
 
andrewf10's Avatar
 
Join Date: Mar 2003
Location: Ireland
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
andrewf10
I finally managed to come up with a neater fix for this problem. Put this behind a save command button:

********************************************

If Me.Dirty = True Then

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Else
MsgBox "No changes have been made to this record.", vbExclamation, "No change"
Exit Sub
End If

********************************************


The thinking is that if the record is locked, a user can't change it and this is what I'm testing for. Isn't Access great?!
__________________
I'm using Access 2000 on Windows 95/98/2000/XP
andrewf10 is offline   Reply With Quote
Old 02-10-2004, 01:40 AM   #10
Mile-O
Back once again...
 
Mile-O's Avatar
 
Join Date: Dec 2002
Location: Glasgow, UK
Posts: 11,312
Thanks: 4
Thanked 117 Times in 107 Posts
Mile-O will become famous soon enough
Quote:
Originally posted by andrewf10
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
That line's obsolete; replace it with:

Code:
DoCmd.RunCommand acCmdSaveRecord
Mile-O is offline   Reply With Quote
Old 02-10-2004, 02:40 AM   #11
andrewf10
Registered User
 
andrewf10's Avatar
 
Join Date: Mar 2003
Location: Ireland
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
andrewf10
Done and thanks
__________________
I'm using Access 2000 on Windows 95/98/2000/XP
andrewf10 is offline   Reply With Quote
Old 02-10-2004, 02:49 AM   #12
Mile-O
Back once again...
 
Mile-O's Avatar
 
Join Date: Dec 2002
Location: Glasgow, UK
Posts: 11,312
Thanks: 4
Thanked 117 Times in 107 Posts
Mile-O will become famous soon enough
For some reason Microsoft change all this code to make it better so we go from DoCmd.DoMenuItem to DoCmd.RunCommand and in the rush to create their products they neglect to update their wizards which generate this dodgy code.

Mile-O is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 11:05 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World