Solved

Combo box rowsourcetype VB function does not work in Acc97

Posted on 1998-05-05
9
539 Views
Last Modified: 2012-05-04
The Combo box rowsourcetype VB function worked in Acc2.0. When I converted the database to Acc97, the VB function in the rowsourcetype property of a combo box is not invoked at all, even though the help documentation inidicates it should work as it did in Acc2.0.

Has anyone been able to populate a combo box in Acc97 using a VB function in the combo box's rowsourcetype property.

I dont normally populate a combo box this way but I had a special application where it works well in Acc2.0 - so im not after alternative ways of populating a combo box - I just want to know why the VB function method isn't working in Access97.

0
Comment
Question by:ozphil
9 Comments
 
LVL 2

Expert Comment

by:marti
ID: 1963024
May I have a look? Could you please send an example to konst@sprint.ca
0
 
LVL 4

Author Comment

by:ozphil
ID: 1963025
Try this out Marti.

In Access 2, create a form and drtag a combo box into it. Assign any fucntion name say 'MyFunction' to the Row Source Type property. Execute the form. An error occurs because the fucntion does not exist. Create a dummy function 'MyFunction' in a module. Execute the form. An error occurs because no arguments are supplied. This is all CORRECT behaviour.

Now try the same thing in Access 97. What do you get? NO ERROR MESSAGES. The Row source type assignment is COMPLETELY IGNORED by Access97.

Its got me baffled. I cant see anywhere where the combo box is a conversion issue.
0
 
LVL 3

Expert Comment

by:guillems
ID: 1963026
Hi!

  Ozphil I check your question, and when I click to see the list of values of the combo-box it makes an error, So with the error event of the form, you can control this.

I hope this help you!
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 4

Author Comment

by:ozphil
ID: 1963027
Hi Guillems.

Could you read the question again please.

In Access97 the combo box VB function assigned to the combo box Row source Type property does not get invoked.

Is this a Micorsoft bug. Is there a Knowledgebase article on the bug.
0
 
LVL 4

Author Comment

by:ozphil
ID: 1963028
Guillems. Dis you get this error message with Access97?
0
 
LVL 5

Accepted Solution

by:
kulikuli earned 100 total points
ID: 1963029
Hi,

I frequently use functions in listboxes and comboboxes as rowsource.
I can remember I once experienced the same problem, because I forgot some little thing to do. I think it might be that you have to put the name of the function in the rowsourcetype property without parentheses and without = .So just the name of the function. This function has to be declared public in a standard module (not in a form's class module).

I just checked it out in one of my applications and it works (in access 97)
Any questions .... tell me.

Best regards,

Kuli
0
 
LVL 4

Author Comment

by:ozphil
ID: 1963030
Thanks kuli kuli.

THere is still a problem here.

You should get a compile error if you name the function in the combo properties to a function name that doesnt exist. Could you do this for me and let me know if you get a compile error. I dont get an error and i should. Access 2 always comes up with an error if you make the slightest mistake. Access 97 shows no errors. It soes not recognise the function.

Something is amiss.




0
 
LVL 4

Author Comment

by:ozphil
ID: 1963031
I have at last got the thing to work.

The problem was with the row and col arguments being declared as integer in Access 2. When I changed the data type to variant in Access97, the function and hence the combo box listing now works.

In Access 2, a syntax error is displayed when the wrong data types are present, but Access 97 presents no error message.

Because you had had success with this I persisted until it worked.

Thanks kulikuli

0
 
LVL 5

Expert Comment

by:kulikuli
ID: 1963032
If you place the name of a not-existing function in the rowsourcetype property of a combobox or listbox and you open the form in normal view then you should get the following message:
'[Functionname]' may not be a valid setting for the RowSourceType property, or there was a compile error in the function.

If you pass a variable to a function, the 'receiving variable' has to be able to receive the passed variable. Passing a long to an integer or vice versa is only possible using ByRef.
In case of passing a long to an integer the long has to be within the range of -32678 to 32767. Otherwise you'll get a compile error.

The intrinsic callback function most apparently has been written in C (most intrinsic functions are stored in a DLL).When the function is called nothing seems wrong because the arguments passed to it are ok. Because it is not part of Access itself, there is no check on the returnvalue that Access receives.
The callback function actually is already compiled (to native code) so it cannot generate a compile error. This is the problem with DLL-functions. You have to know exactly what the function has to receive and what it returns.

Thanx for rewarding me.

Best regards,

Kulikuli
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question