473,387 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Use of "Public Type" in ACCESS 2003

Could you please confirm if 'Public Type', as defined below, is possible with Access 2003. Symilar example found in a book for Access 2007.
Expand|Select|Wrap|Line Numbers
  1. Public Type TypeName
  2.   Type as String
  3.   Temp as Single
  4.   Protect As Boolean
  5. End Type
  6.  
  7. Public Function FnName()
  8.   Dim Var1 as TypeName 
  9.   Dim Var2 as TypeName
  10.  
  11.   ........
  12. End Function
The error message inline 7 is:
User-defined type not defined
Nov 28 '09 #1

✓ answered by orangeCat

I tried your example in Access 2003, by putting
all of the code in an existing module. Access gave me the same error.

Then I put just the
Expand|Select|Wrap|Line Numbers
  1. Public Type TypeName
  2.  Type As String
  3.  Temp As Single
  4.  Protect As Boolean
  5.  End Type
  6.  
in a separate module called ModuleType and saved it.

Then ran this function

Expand|Select|Wrap|Line Numbers
  1.   Public Function FnName()
  2. 'can you use reference a Public Type in Acc 2003
  3.  
  4.    Dim Var1 As TypeName
  5.    Dim Var2 As TypeName
  6.  
  7.    Var1.Type = "this is type"
  8.    Var1.Protect = False
  9.    Var1.Temp = 2
  10.  
  11.    Debug.Print "This is working  >" _
  12.    & Var1.Type & "-" & Var1.Temp & "-" _
  13.    & Var1.Protect
  14.  
  15.   End Function
  16.  
Result
This is working >this is type-2-False

5 4873
orangeCat
83 64KB
I tried your example in Access 2003, by putting
all of the code in an existing module. Access gave me the same error.

Then I put just the
Expand|Select|Wrap|Line Numbers
  1. Public Type TypeName
  2.  Type As String
  3.  Temp As Single
  4.  Protect As Boolean
  5.  End Type
  6.  
in a separate module called ModuleType and saved it.

Then ran this function

Expand|Select|Wrap|Line Numbers
  1.   Public Function FnName()
  2. 'can you use reference a Public Type in Acc 2003
  3.  
  4.    Dim Var1 As TypeName
  5.    Dim Var2 As TypeName
  6.  
  7.    Var1.Type = "this is type"
  8.    Var1.Protect = False
  9.    Var1.Temp = 2
  10.  
  11.    Debug.Print "This is working  >" _
  12.    & Var1.Type & "-" & Var1.Temp & "-" _
  13.    & Var1.Protect
  14.  
  15.   End Function
  16.  
Result
This is working >this is type-2-False
Nov 28 '09 #2
ADezii
8,834 Expert 8TB
There is nothing wrong with the Syntax, but TypeName is the Name of a Built-In Function in Access, and Type is a Built-In Property of several Access Objects. I would bet that this is where the problem lies.
Nov 28 '09 #3
NeoPa
32,556 Expert Mod 16PB
Peter,

I think that the point that orangeCat has highlighted is fundamental here. TypeDefs should be defined in standard code modules. Otherwise, they are much harder to reference and very much less generally useful.

That said, ADezii's comments, while not identifying actual show-stoppers at this stage, are definitely worth taking note of. You are cetainly likely to hit problems if you use names that are already in use elsewhere, even if the problems can be got around with care. Much better to avoid this likelihood.

Lastly, you have tried (by the look of it) to format your code in tags. They weren't the correct tags, but I appreciate the attempt. Perhaps the following will help you to use the correct ones in future. They are designed to be quite easy to use :
You should know that we expect your code to be posted in [code] tags (See How to Ask a Question and indeed the instructions in the posting window itself).

PS. Tags (generally) are done as matching pairs where the opening one is surrounded by [...] and the closing one by [/...]. A set of buttons is available for ease of use in the Standard Editor (Not the Basic Editor). The one for the [code] tags has a hash (#) on it. You can choose which editor to use in your Profile Options (Look near the bottom of the page). You must select the code in your post, and hit the button on the tool bar which looks like a hash (#). This will automatically format the post such that the [code] tags surround the code you're posting. This will display the code in a Code Box, quite differently from the standard formatting of a post.
Nov 29 '09 #4
Many thanks for all the comments, particularly to OrangeCat.

The posted code was tested with different variable names. My objective at the moment is to establish the differences between Access 2007 and 2003. I would like to ensure the work I am doing in 2003 will work in the next version of Access.
Nov 30 '09 #5
You may want to know that the problem reported in ACCESS 2003 does not exist in ACCESS 2007.
Dec 1 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Web Developer | last post by:
Hi, I come across the term "type checking" very often in my readings on C++, and have never heard it in Java. Besides the simplistic answer that it checks the "type", what more does it mean? ...
6
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> ...
4
by: MLH | last post by:
The following function declaration confuses me... Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef sReason As String) As Boolean I tried pasting it and its code into an...
4
by: Jon Shemitz | last post by:
Syntax seems to say "modifiers is modifiers" and either is valid, but Google searches seem to show that "public virtual" is more common. Is there any sort of (semi) official convention? -- ...
4
by: Mike S | last post by:
I'm hoping someone can explain the following. I have installed Visual Studio 2003. Setup several web application projects, compliled and ran them with no problem. All of this was accomplished...
2
by: David Reynolds | last post by:
Hi Everybody, I have a vb.net webform where I create the Excel application/workbook/worksheet. On Windows 2000 server for some reason, I keep getting an error("Bad variable type") when trying...
1
by: timbobd | last post by:
I have encountered a situation that I don't understand. When I call a sub of Friend scope (in an object with Friend scope), I am getting an error "Public member 'subname' not found in type...
10
by: dstorms | last post by:
Hi, I'm trying to create a button on a form that: 1. Takes the ComputerID from the form linked to Table 1, 2. Checks Table 2 for a matching ComputerID, and 3. Opens the query qryEditData, and...
3
by: Matt | last post by:
Hi everyone, can someone point out the difference between defining a class with the public access modifier and just leaving it as it is (default in vs.net "class") I think that the default...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.