Run time error 13 (1 Viewer)

andrewf10

Registered User.
Local time
Today, 04:26
Joined
Mar 2, 2003
Messages
114
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
 

Mile-O

Back once again...
Local time
Today, 04:26
Joined
Dec 10, 2002
Messages
11,316
andrewf10 said:
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.
 

andrewf10

Registered User.
Local time
Today, 04:26
Joined
Mar 2, 2003
Messages
114
But all fields are textboxes. And the exact same code works on the other form...
 

Mile-O

Back once again...
Local time
Today, 04:26
Joined
Dec 10, 2002
Messages
11,316
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.
 

andrewf10

Registered User.
Local time
Today, 04:26
Joined
Mar 2, 2003
Messages
114
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
 

Attachments

  • test1.zip
    27.6 KB · Views: 115

Mile-O

Back once again...
Local time
Today, 04:26
Joined
Dec 10, 2002
Messages
11,316
andrewf10 said:
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.
 

andrewf10

Registered User.
Local time
Today, 04:26
Joined
Mar 2, 2003
Messages
114
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...
 

andrewf10

Registered User.
Local time
Today, 04:26
Joined
Mar 2, 2003
Messages
114
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?
 

andrewf10

Registered User.
Local time
Today, 04:26
Joined
Mar 2, 2003
Messages
114
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?!
 

Mile-O

Back once again...
Local time
Today, 04:26
Joined
Dec 10, 2002
Messages
11,316
andrewf10 said:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

That line's obsolete; replace it with:

Code:
DoCmd.RunCommand acCmdSaveRecord
 

Mile-O

Back once again...
Local time
Today, 04:26
Joined
Dec 10, 2002
Messages
11,316
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.
 

Users who are viewing this thread

Top Bottom