UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> How To Solve: Runtime Error 424 Obkject Required, Access 2003    
 
   
Hein
post Oct 22 2019, 12:10 PM
Post#1



Posts: 493
Joined: 10-November 05
From: The Netherlands


Hi all,

I have trouble with the next code (part of a bigger module that fills a audit trail table)
The reason I use variant is that apparently a string cannot contain a Null value

CODE
Dim Gender_Old as Variant
Dim Gender_New as Variant

If me.cmbGender.OldValue = me.cmbGender.Value Then
   Gender_Old = LCase(me.cmbGender.Column(1).OldValue)
   Gender_New = LCase(me.cmbGender.Column(1).Value)
ELSE
   Gender_Old = UCase(me.cmbGender.Column(1).OldValue & " --->"
   Gender_New = "---> " & UCase(me.cmbGender.Column(1).Value
END IF


Note: cmb Gender consist of 2 columns: 1 = ID, 2 = desciption Men/Female

When I activate the code (meaning: change the record) I get message run time error 424 object required

I thought I defined the object by "Dim Gender_Old as Variant"
What can I do to fix this?

Hein
Go to the top of the page
 
theDBguy
post Oct 22 2019, 12:22 PM
Post#2


Access Wiki and Forums Moderator
Posts: 76,520
Joined: 19-June 07
From: SunnySandyEggo


Hi. Which line is highlighted with the error?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Hein
post Oct 22 2019, 12:24 PM
Post#3



Posts: 493
Joined: 10-November 05
From: The Netherlands


Hi DBGuy!

the line "Gender_Old = LCase(me.cmbGender.Column(1).OldValue)" is highlighted
Go to the top of the page
 
theDBguy
post Oct 22 2019, 12:27 PM
Post#4


Access Wiki and Forums Moderator
Posts: 76,520
Joined: 19-June 07
From: SunnySandyEggo


QUOTE (Hein)
Hi DBGuy!

the line "Gender_Old = LCase(me.cmbGender.Column(1).OldValue)" is highlighted

I see. Try it this way then.
CODE
Gender_Old = LCase(Choose(Me.cmbGender.OldValue,"Men","Female"))

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Hein
post Oct 22 2019, 12:36 PM
Post#5



Posts: 493
Joined: 10-November 05
From: The Netherlands


Thanks,

I tried your suggestion and changed the code, only for the "_Old" -line
Now the highlighted moves to the next (_New) line so I guess that the "_Old" line is correct.

This seems workable for a combobox with only a few records in it (male, female)

Is there a workaround for combo's with a lot of records, e.g. cities people live in?

In my search for the solution I came across something like column(x,y)
I didn't look into it because I thougth it was not the answer
IS it the road to go?

Hein
Go to the top of the page
 
theDBguy
post Oct 22 2019, 12:55 PM
Post#6


Access Wiki and Forums Moderator
Posts: 76,520
Joined: 19-June 07
From: SunnySandyEggo


Hi. The issue is your combobox is bound to a numeric value but you want to store the text value in your audit trail. If you have more items or columns, then you might try using the Column() property. Otherwise, you may have to use DLookup(). Why can't you simply store the numeric value in your audit trail and use another combo to display it in your audit report or audit trail form?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Hein
post Oct 22 2019, 01:10 PM
Post#7



Posts: 493
Joined: 10-November 05
From: The Netherlands


You bring up the DLookup
I was fiddling around a litle and thought that for combo's that refer to a table a dlookup might work

I just have to do a little extra programming and use the old ID (.Oldvalue) and the new ID (.Value) to get the proper outcome
A little extra work but I think it's worth it.


The reason for not using the ID's is pure convenience.
In my audit trail a change from my lastname Vegt to another Vegt makes little sense and doesn't really answer the question why the record was changed.
So I have built an audit trail that stores all actual values old and new (eg lastname, firstname, date of birth, city, nationality etc)

Fields that changes get « ---> » behind it (old values) or before (new values)
Also they are in capital letters
The fields that don't change are in lower case
This way I can easily see where the changes are
Also: if there is more than 1 change I can see the entire history right before me.

Different from what most people do but for me it works

Thanks you again for helping me out! thumbup.gif

Hein
Go to the top of the page
 
theDBguy
post Oct 22 2019, 01:17 PM
Post#8


Access Wiki and Forums Moderator
Posts: 76,520
Joined: 19-June 07
From: SunnySandyEggo


Hi. You're welcome. Let us know how it goes. Good luck!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    14th November 2019 - 01:51 AM