Adding user defined datatypes to a form

  • Thread starter Thread starter OoKiE
  • Start date Start date
O

OoKiE

In Access 2002, I am trying to add objects which are user
defined datatypes to a form. I then want to set the object
in the form to equal an object of the same type from
within another module.

Maybe the 'pseudo code' below will explain my intentions
better.


Module - Constants
------------------
Public Type Question
Question As String
QuestionID As Integer
End Type


Module - Main
-------------
Sub DoStuff()
Dim AskQuestion as Question

AskQuestion.Question = "Can this work?"
AskQuestion.QuestionID = 1

form_AskStuff.Store = AskQuestion ' This bit is not working

DoCmd.OpenForm "form_AskStuff"

End Sub


Module - form_AskStuff
----------------------
Option Compare Database
Option Explicit
'This bit is not working, and is probably the
'wrong way doing this but hopefully shows my intentions.
Dim Store as Question

Private Sub Form_Open(Cancel As Integer)
Btn1.caption = Store.Question
..
 
OoKiE said:
In Access 2002, I am trying to add objects which are user
defined datatypes to a form. I then want to set the object
in the form to equal an object of the same type from
within another module.

Maybe the 'pseudo code' below will explain my intentions
better.


Module - Constants
------------------
Public Type Question
Question As String
QuestionID As Integer
End Type


Module - Main
-------------
Sub DoStuff()
Dim AskQuestion as Question

AskQuestion.Question = "Can this work?"
AskQuestion.QuestionID = 1

form_AskStuff.Store = AskQuestion ' This bit is not working

DoCmd.OpenForm "form_AskStuff"

End Sub


Module - form_AskStuff
----------------------
Option Compare Database
Option Explicit
'This bit is not working, and is probably the
'wrong way doing this but hopefully shows my intentions.
Dim Store as Question

Private Sub Form_Open(Cancel As Integer)
Btn1.caption = Store.Question
.

That sure looks like a roundabout way of setting a caption,
but I think(?) your problem is that you do not know which
instance of the form's class module you're referring to with
the syntax

form_AskStuff.Store = . . .

Try doing it this way

DoCmd.OpenForm "AskStuff"
Forms!AskStuff.Store = AskQuestion

but that won't do it either because the Open event will have
completed by then.

Is there a reason why you don't use OpenArgs to do this?
 
Back
Top