Initializing a user-defined type

Is there any quick way to initialize such a type when all the  elements in it 
are the same e.g.

Public Type typDates
   Date1 As Date
   Date2 As Date
   Date3 As Date
   Date4 As Date
   Date5 As Date   
End Type

0
Utf
10/29/2007 11:20:01 PM
access.formscoding 7493 articles. 0 followers. Follow

1 Replies
1889 Views

Similar Articles

[PageSpeed] 35

I'm not sure what you have in mind when you say you want to quickly 
initialize the elements, but...

When you declare a variable as your type, its elements will be initialised
to zero (as each element is a date type), as demonstrated by the following
example:

Public Type typDates
  Date1 As Date
  Date2 As Date
  Date3 As Date
  Date4 As Date
  Date5 As Date
End Type

Public Sub TestType()

    '    Run this code to see zeros in the Immediate window.

    Dim usrDates As typDates

    Debug.Print usrDates.Date1
    Debug.Print usrDates.Date2
    Debug.Print usrDates.Date3
    Debug.Print usrDates.Date4
    Debug.Print usrDates.Date5

End Sub

If you need a specific default value for each element, you could declare a
public or private variable at the module level and call a subroutine that
initialises the elements, as demonstrated by the following example:

Public usrMyDates As typDates

Public Type typDates
  Date1 As Date
  Date2 As Date
  Date3 As Date
  Date4 As Date
  Date5 As Date
End Type

Public Sub SetDefaultDates()

    ' Call this subroutine like this:
    '    Call SetDefaultDates

    ' FIRST EXAMPLE:

    usrMyDates.Date1 = DateSerial(2007, 11, 2)
    usrMyDates.Date2 = DateSerial(2007, 11, 3)
    usrMyDates.Date3 = DateSerial(2007, 11, 4)
    usrMyDates.Date4 = DateSerial(2007, 11, 5)
    usrMyDates.Date5 = DateSerial(2007, 11, 6)

    Debug.Print usrMyDates.Date1
    Debug.Print usrMyDates.Date2
    Debug.Print usrMyDates.Date3
    Debug.Print usrMyDates.Date4
    Debug.Print usrMyDates.Date5


    ' SECOND EXAMPLE:

    usrMyDates.Date1 = Now()
    usrMyDates.Date2 = Now()
    usrMyDates.Date3 = Now()
    usrMyDates.Date4 = Now()
    usrMyDates.Date5 = Now()

    Debug.Print usrMyDates.Date1
    Debug.Print usrMyDates.Date2
    Debug.Print usrMyDates.Date3
    Debug.Print usrMyDates.Date4
    Debug.Print usrMyDates.Date5

End Sub

Geoff



"mscertified" <rupert@tigerlily.com> wrote in message
news:F16B5073-212C-42A6-9BF8-63357799A16F@microsoft.com...
> Is there any quick way to initialize such a type when all the  elements in
> it
> are the same e.g.
>
> Public Type typDates
>   Date1 As Date
>   Date2 As Date
>   Date3 As Date
>   Date4 As Date
>   Date5 As Date
> End Type
>





0
GeoffG
11/2/2007 9:21:33 PM
Reply:

Similar Artilces:

How to re-enable user?
Hi, In MS-CRM 1.2, I've disabled a user in Users Settings. However, I couldn't find any menu that I can re-enable the user..... How can I re-enable the disabled user? Thanks. ...........................................................TJ You can access the disabled user via the "Disabled Users" view and once you open up the user, you can enable it via the Actions menu. Matt Parks MVP - Microsoft CRM ---------------------------------------- ---------------------------------------- On Fri, 4 Feb 2005 15:21:02 -0800, "TJ" <TJ@discussions.microsoft.com> wr...

data type mis match error
I am getting a Compile error: Type-declaration character does not match declared data type Private Sub optMH1_Click() Call SelectMHform(1) End Sub Sub SelectMHform(a As Integer) With Forms("BaseForm") .optMH& a&.value = 1 .txtPicture.value = "MH" + Str(a) .cmbBoxMaterial.value = "" .txtBoxLength.value = "" End With End Sub I tried some other things too but I am still getting an error due to .optMH& a&.value = 1 How do I use a variable in this situation? "dannie" <dannie@discussions.microsoft....

Dropped Initial Word
I have Office 2007 Word running on XP Service Pack 2. I know how to make a drop cap for the starting paragraph in a paper. Is there any way to make the entire first word drop 2 or 3 lines depending on what I need? As an example if I were to type the sentence "Now is the time for all good men to come to the aid of their country." I would want to drop the word Now not just the N. Select the whole word and then apply drop cap formatting. -- Stefan Blom Microsoft Word MVP "Deej Hernandez" <DeejHernandez@discussions.microsoft.com> wrote in message...

GetUserName API user case
Hi GetUserName API in win2000 returns the username in the exact case in which user was created where as in case of windows xp it returns the in a case that user has keyed in during log in to the machine. Can you tell me how can i get this XP behaviour in Win2000 ...

how do I define a rule that forwards an email alert to my cell ph.
Outlook's online help states that you can setup an email to forward to your cell phone, but how do I specify my cell phone as an email address? Other users on the Exchange Server have done this and I would like to as well. ...

View the contents of a users mailbox.
Our exchange server is having issues, and we want to take the mail from the existing boxes, and send it (per user) to another set of email addresses. Can we do this? Alternativly, can I have exchange forward all the mail in everyones existing mailbox, to a single email address, so I can just pick it up there, and redistribute it. -- Patrick Blanche IT Professional ITPROExpert@yahoo.com How about just build another Exchange server and move the mailboxes? Better yet, how about telling us what's wrong and maybe we can help you fix it? "Patrick Blanche" <itproexpert@...

Constructor initialization
Hi, Why do CMyClass::CMyClass() : m_iMyInt(0) // initialize { } instead of CMyClass::CMyClass() { m_iMyInt = 0; // assign } The first seems preferred, but I've always done the second (Self taught C++ so I don't know all the theory). Hi, When a class is instantiated, and for the purposes of this post lets leave inherited classes out of the picture, after the physical memory is allocated the members constructors are called and then the classes own constructor. When the members are constructed, the default constructor is called and then when your constructor executes th...

Automatic shift of cursor while typing
I using Windows Office Word 2007. Often when I'm typing a document the cursor automatically shifts from where I'm typing to another place in the document where I've previously typed. For example, I might be typing "the quick brown fox jumped the log" and while I'm typing, say, "fox", the cursor will jump to the middle of a sentence previously typed on that page. Has anyone else had this problem and, if so, can you tell me how to correct the problem? Thanks. Laptop? Turn off the touchpad or reduce its sensitivity. -- Suzanne S. Ba...

excel vba
Is there a way to set up a workbook so that more than one user ca access the workbook at the same time. For instance, I have set up a invoicing program. When the user clicks on the shortcut to open th program, it automatically generates a sequential invoice number. have to go in and out of the program periodically throughout the da for certain purposes, and this is causing errors because whoever trie to go in second has to open the program read only. Is there some wa that user 1 can go into the program, and then have user 2 go into th same program without causing any read only situations ...

faq initialize CList
Hi, I have a member viarable of CList<CPoint,CPoint&> m_pointlist in Class Segment. Should I have to initialize the m_pointlist in Segment constructur? Thanks. The CList has a constructor with a default parameter (block size = 10). If that number satisfies you, you do not need to worry about initialization. Otherwise, follow this syntax: class Segment { private: CList<CPoint, CPoint&> m_pointList; public: Segment() : m_pointList( 100 ) // Place your own number instead of 100... { } } or class Segment { private: CList<CPoint, CPoint&> m_point...

Question about spammers users using SMTP
All, First, I'd like to apologize, I know almost nothing about Exchange. But our office has the following problem 1) We have a relatively old exchange version, installed on Win NT about 4-5 years ago. (I know we need to upgrade, but that a sep issue) 2) We used to be an independant company, and when we were bought by our parent company, we kept the exchange server, b/c a lot of customer service emails go to folders on it and need to be accessible easily locally, plus the corporate mail hasn't been as stable. 3) The spam problem was increasingly becoming a problem, so we changed origi...

User defined type not defined?
This is a multi-part message in MIME format. ------=_NextPart_000_0023_01CADCBA.E1E83600 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello All I have recently been having some VBA corruption problems, which I have = been taking steps to sort out - one of which has been to do = Debug>Compile db1 after every amendment I make to any of the code. I = have noticed 3 different outcomes of the Debug>Compile db1: 1. Sometimes I get a message "User defined type not defined" - but the = cursor does not move to a...

Changing initials into numbers
I have data that I download into Excel and initials are used for different people. I need to give those initials a number in excel for example MJ = 01, HS = 02..etc. Thank you. On 2/3/2010 9:26 AM, Kathie wrote: > I have data that I download into Excel and initials are used for different > people. I need to give those initials a number in excel for example MJ = 01, > HS = 02..etc. Thank you. see VLOOKUP in Excel help. Bill Kathie You have to be more specific. Where are the initials (column, row, sheet)? Where do you want the numbers placed? HTH Otto &quo...

View List of Connected Users in Business Portal
Prior to rebooting or applying patches to Business Portal server, we need to view and see list of connected users in Business Portal so we can ensure we do not accidentally disconnect them while they are working. I understand we can view who has what databases open in SQL server hosting the Great Plains database where we can view activities. However, it would be nice to view within Business Portal server who is connected and have ability to notify those users to disconnect or that server is going offline. Thanks, Shelley ---------------- This post is a suggestion for Microsoft, and Mi...

crm mobile express error: Exception of type 'System.Web.HttpUnhandledException' was thrown.
I'm able to access crm mobile express webpage. I'm able to show account directory, search for account. but when I try to open one account, I get an error: please help!!! An Error has Occured -------------------------------------------------------------------------------- Go Back Try Again Message: Exception of type 'System.Web.HttpUnhandledException' was thrown. Stack trace: at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(B...

CC: name showing user ID rather than full name
Why would the name in the cc:, etc. fields show as the user ID rather than the display name or email address Is this a pop quiz or did you want some help with this? If the latter, provide some information. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching google.groups.com and finding no answer: anonymous@discussions.microsoft.com <anonymous@discussions.microsoft.com> asked: | Why would the name in the cc:, etc. fields show as the | user ID rather than the display name or email address ...

Possible to Look Up Records by Initials?
I have a user who's telling me that prior to this weekend in CRM, she could lookup user records by initials rather than typing in part of the name. I don't see where that setting would have been marked in CRM. Has anyone else heard of this? If so, how did you implement this type of search customization/configuration? Steps to recreate problem: Account screen Account Owner field's magnifying glass Assign Account Assign to another user fields magnifiying glass Look Up Records' Look For field = initials of user you're attempting to Find. I doubt you can use the init...

Capture initial value of text box
Not sure why I can't seem to get this to work, but here's what I'm trying to do: I have a text box, 'Actual_Due_Date', tied to a field in a table. In the same table is a text box named 'Org_Due_Date'. When the initial value is set in the 'Actual' field, I want to capture and store it permanently in the 'Org' field. I have two forms, a New Project form and an Edit Project form. My thought was to just setup a simple macro in the New Project form in the 'Actual' field that says After Update set the 'Org' field equal to the 'A...

User setup in Exchange 2003 does not auto create mailbox
Does anyone know what would cause this to happen. The mailbox will not be created in the mailbox store until that user logs into the mailbox or a message is sent to the mailbox. "lgresham" <anonymous@discussions.microsoft.com> wrote in message news:2bdd701c468d7$5b4dcfe0$a401280a@phx.gbl... > Does anyone know what would cause this to happen. Is there a way to get aroud this? I would like to "import" new users from an Excel spreadsheet and have their accounts/mailboxes ready to use without the required login (this is due to many users using OWA only) "...

User Breakpoint in CEdit
If I run my application in debug mode, every time I enter a 0 (zero) into any CEdit control, the debugger pops up saying it hit a user breakpoint. I can dismiss the message box and hit F5 to continue on, but this is annoying. Does anyone know why this is happening and how to stop it? Show an example of the code you are using. What this breakpoint means is that you have done something erroneous. The way to stop it is to not commit that error, whatever it is. But without seeing an example of the code, it is impossible to guess what you might be doing. Also: what is the traceback to your call...

Remove middle initial from "first name middle initial"
Hello Excel Gurus, I've been searching the site for an answer to this question but as yet no luck. If I missed a previous post on this topic I apologize, please direct me to it. I have 1 column with a series of people's first names. Many have a middle initial, some don't. About half of the cells are of two people's names joined by an "&". Sample data below: Frank & Debbie J Marshall & Teresa Timothy R Jeffrey D & Eileen N Pamela J James R & Rachel Brooke S Myung S Martin F & Susan A Kathleen I need remove the middle initial and preserve...

select user from ....
Help please. In an Oracle database I can identify the current user with the statement "SELECT USER FROM DUAL;" Can I do something similar in MS Access? "William" <William@discussions.microsoft.com> wrote in message news:4F99ABE3-B160-4412-B035-EC54AF8EE367@microsoft.com... > Help please. In an Oracle database I can identify the current user with > the > statement "SELECT USER FROM DUAL;" Can I do something similar in MS > Access? The VBA function CurrentUser() returns the name of the user logged into the database. (Note that ...

how to block POP access for certain users?
hi, i want to block certain users from accessing the exchange 2003 server through POP3. i saw it could be done through IP address but i dont want that, i just want it to be based on user ID. is there any way i can do that ? thanks, akhlaq khan. Set access in AD under Exchange Advanced - Protocol settings "Akhlaq Khan" <akhlaq.khan@pk.softechww.com> wrote in message news:eVXGfmsCFHA.2600@TK2MSFTNGP09.phx.gbl... > hi, > i want to block certain users from accessing the exchange 2003 server > through POP3. > i saw it could be done through IP address but i dont wan...

Opening other users mailbox
We have a common mailbox that several users are supposed to access, but on some computers/users the "open other users folder" option is greyed out. Where can this be changed? Do they have appropriate permissions? Best practice is to assign permissions once to a security group and simply make anyone needing permissions a member of that group. The specific permissions required: 1) Send As 2) Receive As 3) Full Mailbox Access. Check this URL for a good explanation: http://www.microsoft.com/technet/prodtechnol/exchange/guides/WorkingE2k3Store/e67725bb-8792-4bac-82aa-429fb6ecd8d9.m...

restriction for remote web user/remote desktop user
Is there any settings on SBS03 that allows us to manage which user/computer/ip address can connect to SBS03 network from remote site, as we would like only certain users from certain computers be able to connect on certain time remotely. If it can not be done then what would be the solution. Thank you. Jack2 wrote: >Is there any settings on SBS03 that allows us to manage which >user/computer/ip address can connect to SBS03 network from remote site, as >we >would like only certain users from certain computers be able to connect on >certain time remotely. If it ...