Re: Problem with Data Types



If frmTo is open in its own right (i.e. not as a subform), you can refer to it using the string name like this:
Forms(frmTo)

But it would be better to pass in a reference to the form itself (ie As Form, not As String) so it works with subforms and sub-subforms.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"cinnie" <cinnie@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:82CE8CBE-B70E-42D1-BCFA-02CB8B2C9C74@xxxxxxxxxxxxxxxx
hi to all
I am writing a function whose parameters are the form that is active when
the function is called (frmFROM), and the form that the function then opens
(frmTO).

My problem is that the frmTO is used as a string in line 5 and 8, but as a
form in line 6. Whichever way I Dim frmTO, I get a crash. How can reslove
this problem?

1 Function ReturnToMenu(frmFROM As Form, frmTO As String)

2 frmFROM.Visible = False
3 Dim prj As Object
4 Set prj = Application.CurrentProject

5 If prj.AllForms(frmTO).IsLoaded Then
6 Forms!frmTO.Visible = True
7 Else
8 DoCmd.OpenForm frmTO
9 End If
10 .....

much thanks
--
cinnie

.



Relevant Pages

  • Re: Problem with Data Types
    ... I can see why it it better to pass in a reference to the form itself, ... frmTO As Form), but I'm struggling with the proper syntax. ... it using the string name like this: ... > 3 Dim prj As Object ...
    (microsoft.public.access.formscoding)
  • Re: Problem with Data Types
    ... I can see why it it better to pass in a reference to the form itself, ... frmTO As Form), but I'm struggling with the proper syntax. ... it using the string name like this: ... Dim prj As Object ...
    (microsoft.public.access.formscoding)
  • Re: finding how much the file system is full, from a C program?
    ... If string is a null pointer, the system function determines whether the host ... The fopen function opens the file whose name is the string pointed to by filename, and associates a stream with it. ... wb truncate to zero length or create binary file for writing ...
    (comp.lang.c)
  • Re: Command button to open form and find record
    ... Opens the form if it is not already open. ... Public Function OpenFormTo(strForm As String, strWhere As String, Optional bGotoNewRecord As Boolean, _ ... Optional strOpenArgs As String) As Boolean ... Public Function HasProperty ...
    (microsoft.public.access.forms)
  • Re: Command Button linked to SubForm
    ... record in some subform on form f_ProvEDIT??? ... parent form and the form I need to open and it opens the correctly linked ... Dim stLinkCriteria As String ...
    (microsoft.public.access.formscoding)

Loading