Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 19th, 2004, 07:03 PM
Authorized User
Join Date: Aug 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using a user defined type and the Split Function

Hey guys,

I have another problem with the split function. I can get the split funtion to work fine for user-defined types (String, integer, ect..) What I want to do is get the Split function to work on a user-defined type. Here is my user-defined definition that I created in a module:

Public Type MyStruct
    First As String
    Last As String
    Phone As Long
    Salary As Double
End Type

Here is the code I am trying to use to send the contents of the split string into this type:

Option Compare Database
Option Explicit

Private Container As MyStruct

Public Sub Command0_Click()
Dim s As String
s = "Tim Mcarthy 8889099221 13000.93"

Container = Split(s, " ")

MsgBox Container.First
MsgBox Container.Last
MsgBox Container.Phone
MsgBox Container.Salary
End Sub

This is the error message I am receiving:
"Only user defined types defined in public object modules can be coerced to form a variant or passed to late bound function"

Any suggestions?

Old August 20th, 2004, 03:50 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post

No chance! You'll have to put it in the UDT yourself, Split won't do it for you.
Old August 20th, 2004, 12:02 PM
Authorized User
Join Date: Aug 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts

Yea, I figured out that a pre-defined function is not going to work for a user-defined type



Similar Threads
Thread Thread Starter Forum Replies Last Post
ADODB.Connection user-defined type not defined Wall st Guru Excel VBA 2 March 26th, 2014 03:44 PM
Setting variable to user defined type mantle51 SQL Server 2000 3 August 10th, 2007 03:52 AM
User-defined type not defined (Icecream.mdb) dloren01 BOOK: Beginning Access VBA 0 June 22nd, 2005 10:36 PM
Split Function type mismatch error nikotromus Access VBA 4 August 19th, 2004 12:46 PM
Table and User Defined Type with same Name djuricd SQL Server 2000 3 April 20th, 2004 12:33 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.