Solved

VB5 - Active X Control - Attribute as a keyword???

Posted on 1998-01-28
8
295 Views
Last Modified: 2013-11-25
Hi,

I'm working my way through "Teach Yourself Database Programming with VB5 in 21 days" by SAMS Publishing.

Things being interesting because there are discrepancies between
what is printed on the page and what is supplied on the CD ROM.

So far I've managed to figure out what was wrong but this one has got me.

Day 12, building an Active X control to select from a list.

When I load up the CD rom version and compile it, it works.

When I load up the code I've typed in, it doesn't.

When I load up the ctl file into a text editor, I see that the CD
version has extra commands in the property definitions, like
Attribute DatabaseName.VB_ProcData.VB_Invoke_Property = "General;Data"

So, how is this command set, because when I type it in, VB5 doesn't
recognise it. How can I set it? I don't know if this is the cause of
why the typed in version doesn't work but it's a difference I've found.

Let me know if you need more details. TIA
0
Comment
Question by:alanlam
  • 5
  • 2
8 Comments
 
LVL 8

Expert Comment

by:mrmick
ID: 1453907
Click Project, References, and then check Microsoft DAO 3.5 Object Library, and add the missing code that you found on the CD-ROM.

0
 

Author Comment

by:alanlam
ID: 1453908
The Microsoft DAO 3.5 Object Library is already referenced.

The "attribute" bit of code from the program on the CD ROM doesn't appear when form is opened up using VB5.
It appears in the .ctl file when you open it up with notepad.

VB5 doesn't recognise the "attribute" keyword.
And, I can't find any mention of the attribute keyword in help files.
So somehow, those attributes are being set somewhere. Where?


0
 
LVL 8

Expert Comment

by:mrmick
ID: 1453909
I see, search help on "Procedure Attributes Command"

Click Tools, Procedure Attributes.


0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:alanlam
ID: 1453910
Tools, Procedure Attributes looks promising but...
I'm a newbie to VB5 programming.

The .ctl code on the CD ROM (when opened with notepad) is :
Public Property Get DatabaseName() As String
Attribute DatabaseName.VB_ProcData.VB_Invoke_Property = "General;Data"
Attribute DatabaseName.VB_MemberFlags = "200"
    '
    DatabaseName = frmFind.Data1.DatabaseName
    '
End Property

Now, I can select property DatabaseName, but then I can't see anywhere to type in
DatabaseName.VB_ProcData.VB_Invoke_Property = "General;Data"

I'm sure we're getting somewhere, I just need more detailed instructions :-)

Supplementary side questions - what does this do, where can I find more info about it and why didn't the authors include it in the book? Is it very complicated or might have been set in a previous project when they renamed it?
0
 
LVL 6

Accepted Solution

by:
anthonyc earned 100 total points
ID: 1453911
This is not a command you can type in.  Using the Procedure Attributes command, you have your properties/methods RESEMBLE the common properties.  Making the DatabaseName property resemble the data controls databasename property allows your control to be a databound control.  This is not something you set in code.  You set this using the Procedure Attributes Screen.  

One of the most common uses of this type of thing is with the enabled property.  You can make a property on yoru control called Enabled, and put all the proper code you would like, but it will not function like expected.  This is because the enabled property is handled by the container object (the form you put the control on) and is a special type of property.  By setting the Procedure Attribute of your Enabled property to ENABLED, you tell VB to treat this like a normal enabled property.  You provide the code, but VB handles the messaging properly!

Hope this helps!
0
 

Author Comment

by:alanlam
ID: 1453912
Very close now. You didn't directly answer my question but the phrase that helped was "you tell VB to treat this like a normal enabled property"

After having yest another hard look at the differences between the two projects I noticed that under Advanced/Use this page in/Property - it was set to Data as opposed to (none) in my typed in version. Also
Advanced/Attributes/User Interface Default was ticked on the CD ROM version, but not on the one typed in. It didn't tell you to do any of this in the book Argggggghhhh.

Now DatabaseName properties under notepad has
Attribute DatabaseName.VB_ProcData.VB_Invoke_Property = ";Data"
Attribute DatabaseName.VB_MemberFlags = "200"

The first line is set by Advanced/Use this page in/Property/Data.
The second line is set by Advanced/Attributes/User Interface Default set to ticked.

Very, very close, but the typed in program still doesn't work.

So for the final part of my original question, how do I, from within VB5, get the first line to include "general" in it? Tell me step by step, even if it is obvious, because I think I'm going blind from looking at the same screens over and over again :-)

TIA
0
 

Author Comment

by:alanlam
ID: 1453913
Very close now. You didn't directly answer my question but the phrase that helped was "you tell VB to treat this like a normal enabled property"

After having yest another hard look at the differences between the two projects I noticed that under Advanced/Use this page in/Property - it was set to Data as opposed to (none) in my typed in version. Also
Advanced/Attributes/User Interface Default was ticked on the CD ROM version, but not on the one typed in. It didn't tell you to do any of this in the book Argggggghhhh.

Now DatabaseName properties under notepad has
Attribute DatabaseName.VB_ProcData.VB_Invoke_Property = ";Data"
Attribute DatabaseName.VB_MemberFlags = "200"

The first line is set by Advanced/Use this page in/Property/Data.
The second line is set by Advanced/Attributes/User Interface Default set to ticked.

Very, very close, but the typed in program still doesn't work.

So for the final part of my original question, how do I, from within VB5, get the first line to include "general" in it? Tell me step by step, even if it is obvious, because I think I'm going blind from looking at the same screens over and over again :-)

TIA
0
 

Author Comment

by:alanlam
ID: 1453914
Blast - forgot to hit reject answer. Could you answer the last comment please. Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 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