Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: If Null Value


Message #1 by "KennethMungwira" <KennethMungwira@Y...> on Mon, 29 Oct 2001 21:11:17
Dear Sir or Madam,

If there is no information to be entered on a form that has this code 

behind my 'Edituodo' Button I run into problems. Can anyone help me with 

an If Null value return to 'Change this Record'







Private Sub cmdEditUndo_Click()

On Error GoTo Err_cmdEditUndo_Click

    

    Dim ctl As Control

    With cmdEditUndo

        If .Caption = "Change This Record" Then

            ' Change the font color and caption

            ' of the cmdEditUndo button

            .Caption = "Undo All Changes"

            .ForeColor = vbRed

            ' Change the caption of the form Headers

            lblHeader1.Caption = "Edit Study"

            lblHeader2.Caption = "Edit Study"

            ' Allow editing of the main and sub forms

            Call FormPermits(True)

            ' Copy the data from each combobox's and textbox's

            ' Control Source property to each control's

            ' tag property

            For Each ctl In Me.Controls

                Select Case ctl.ControlType

                    Case acComboBox, acTextBox

                        If Not IsNull(ctl) Then

                            ctl.Tag = ctl

                        End If

                End Select

            Next ctl

            ' Do the same for the subform's fields

            For Each ctl In Me!StudySpec.Form

                Select Case ctl.ControlType

                    Case acComboBox, acTextBox

                        If Not IsNull(ctl) Then

                            ctl.Tag = ctl

                        End If

                End Select

            Next ctl

          

         Else

        

            ' Change the font color and caption

            ' of the cmdEditUndo button

            .Caption = "Change This Record"

            .ForeColor = vbBlue

            ' Change the caption of the form Headers

            lblHeader1.Caption = "View Study "

            lblHeader2.Caption = "View Study "

            ' Undo any changes by copying the data from

            ' the control's Tag property to the control's

            ' Control Source property

            For Each ctl In Me.Controls

                Select Case ctl.ControlType

                    Case acComboBox, acTextBox

                        If Len(ctl.Tag) > 0 And ctl.Name <> "StudyID" Then

                            ctl = ctl.Tag

                        End If

                End Select

            Next ctl

             ' Do the same for the subform's fields

            For Each ctl In Me!StudySpec.Form

                Select Case ctl.ControlType

                    Case acComboBox, acTextBox

                        If Len(ctl.Tag) > 0 Then

                            ctl = ctl.Tag

                        End If

                End Select

            Next ctl

            ' Do not allow editing of the main and sub forms

            Call cmdSave_Click

 '          Call FormPermits(False)

 'MsgBox "else"

        End If

    End With

    

Exit_cmdEditUndo_Click:

    

    Exit Sub



Err_cmdEditUndo_Click:

    MsgBox Err.Description

    Resume Exit_cmdEditUndo_Click

    

End Sub

Message #2 by "John Ruff" <papparuff@c...> on Tue, 30 Oct 2001 01:19:18 -0800
Kenneth,



Place a rem statement before the On Error GoTo line then run the

program.  Tell me what line is causing the error.







John Ruff - The Eternal Optimist :-) 



Message #3 by Kenneth Mungwira <kennethmungwira@y...> on Tue, 30 Oct 2001 06:29:16 -0800 (PST)
 After applying the Rem Statement I still get the error:

MicroSoft- You have entered an Expression that has an invalid reference to 

the Property Form/Report.

 

Please help





Message #4 by Kenneth Mungwira <kennethmungwira@y...> on Tue, 30 Oct 2001 06:44:19 -0800 (PST)
 The form which I have created has two nested forms resting in the one main 

form. Unfortunately the main form will always have information backing it, 

but the two nested forms will not.  This is where I am running into 

problems, with the code and excuting my command buttons which are located 

in one of my nested forms. Some of my nested forms will not have any 

information to back them but, will need to be editted. 



  John Ruff <papparuff@c...> wrote: Kenneth,



Place a rem statement before the On Error GoTo line then run the

program. Tell me what line is causing the error.







John Ruff - The Eternal Optimist :-)


  Return to Index