Form Load & IsNull (1 Viewer)

kirkm

Registered User.
Local time
Today, 22:09
Joined
Oct 30, 2008
Messages
1,257
This is a custom Msgbox where I can pass the captions and get the result.
It works but I cannot understand why I need to IsNull check.

This often is the case on try 1 (just after writing the code). Even with Openargs passed it shows up as Null.
You have to close the Form and open it a second time, then it's ok.

But also in this case the Form_Load event seems to run again after the Form is Hidden/closed.

Why is this ?
I also tried Form_Activate instead of Form_Load but that doesn't even run. Should it ?
Thanks
--
Code:
Public Sub cmdNotes_Click()
    Dim fCaption As String
    Dim Button1Caption As String
    Dim Button2Caption As String
    Dim a As Integer
    fCaption = "Move last bracketed text in Title to Notes" & Chr$(1)
    Button1Caption = "Whole Disk" & Chr$(1)
    Button2Caption = "This Record Only" & Chr$(1)

    DoCmd.OpenForm "frmMsgbox2", acNormal, , , , acDialog, fCaption & Button1Caption & Button2Caption
    a = Form_frmMsgBox2.Result
    DoCmd.Close acForm, "frmMsgbox2"
    
    MsgBox a
End Sub

Code:
Option Compare Database
Option Explicit
Public Answer As Integer

Private Sub btn1_Click()
    Answer = 1
    Me.Visible = False
End Sub

Private Sub btn2_Click()
    Answer = 2
    Me.Visible = False
End Sub

Sub Form_Load()
    If Nz(Me.OpenArgs) <> "" Then
        Me.Caption = Form_frmCDMain!Title
        Me.lblPrompt.Caption = Split(Me.OpenArgs, Chr$(1))(0)
        Me.btn1.Caption = Split(Me.OpenArgs, Chr$(1))(1)
        Me.btn2.Caption = Split(Me.OpenArgs, Chr$(1))(2)
    End If
End Sub

Public Property Get Result() As Integer
    Result = Answer
End Property
 

moke123

AWF VIP
Local time
Today, 05:09
Joined
Jan 11, 2013
Messages
3,849
I'm not sure I'm following your requirements. Its late and I just cant picture it.

Heres a custom messagebox which uses the native msgbox with a custom caption, message , button captions and icon.
See if this is any help
you call it with one line of code like
Code:
Me.Flavor = fCustomMsgBox(3, "Chocolate,Vanilla,Strawberry", "Select a Flavor", "Ice Cream Flavor", True, vbExclamation)
Click the begin button to see how it works
 

Attachments

  • CustonNativeMessageBox.accdb
    548 KB · Views: 420
Last edited:

kirkm

Registered User.
Local time
Today, 22:09
Joined
Oct 30, 2008
Messages
1,257
Hi Arne, I've become a very skeptical of such links e.g. one of the things it says is
When you open a form, the following sequence of events occurs for the form:
Open
arrow
Load
arrow
Resize
arrow
Activate
arrow
Current

But a Stop in the Activate event is never executed.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:09
Joined
May 7, 2009
Messages
19,169
It does fire on Main form (not on subform).

the best way is to test it.
create a form, and add code to those events, eg:

private sub form_open(cancel as integer)
'should be the first event
msgbox "1. Open Event triggered"
end sub

private sub form_load()
'supposed to be the 2nd event
msgbox "2. Load Event triggered"
end sub

'do the same to the rest of events
 
Last edited:

kirkm

Registered User.
Local time
Today, 22:09
Joined
Oct 30, 2008
Messages
1,257
All showed except the Activate. Does it for you ?
 

kirkm

Registered User.
Local time
Today, 22:09
Joined
Oct 30, 2008
Messages
1,257
Thank you Bob, that explains that.
 

kirkm

Registered User.
Local time
Today, 22:09
Joined
Oct 30, 2008
Messages
1,257
Moke123, Thanks I like your Custom Msgbox and think I'll bin mine. It's much more sophisticated ! And I had that Form Load running twice problem which must be just Access acting weird.
 

Users who are viewing this thread

Top Bottom