[mso] Re: Access VB Code Needed (more)

  • From: "Colli, Anthony G" <Anthony.Colli@xxxxxxx>
  • To: "'mso@xxxxxxxxxxxxx'" <mso@xxxxxxxxxxxxx>
  • Date: Fri, 3 Jan 2003 15:13:41 -0500

April-

txtCltResponName = "txtCltFName" & "txtCltLName" 
will always equal "txtCltFNametxtCltLName"
so you might want to try 

Private Sub cbxCltRespon_AfterUpdate()
If Me.cbxCltRespon.Value = True Then
        DoCmd.OpenForm "sfrmContactResponParty"
    Else
            me.txtCltResponName = me.txtCltFName  & ", " me.txtCltLName
    End If

End Sub

Try to use the me. object when referenceing controls. (Me.) just refers to
the parent form. It helps alot when it comes time to debug. 

When testing controls for a value your best bet is the IsNull function. 

If IsNull(Me.cbxContRespon) And IsNull(Me.cbxCltRespon) Then

If your trying to validate some data based on a value in a different control
you can use the BeforeUpdate event. Basically the BeforeUpdate fires before
the changes occur in the database. And you can cancel the event if you find
the conditions are not met. No data will be saved into the database this
way. The AfterUpdate event fires after the data has been committed and
therefore saved, you may or may not want this. 


 & (Chr(13) & Chr(10)) will add a new line in a message box:


MsgBox "You have stated that the Responsible party is the client " & Chr(13)
& Chr(10) & " The Contact Name MUST be different"

-Anthony





-----Original Message-----
From: April Pace [mailto:4office@xxxxxxxxxxxxx]
Sent: Friday, January 03, 2003 2:37 PM
To: Office (E-mail)
Subject: [mso] Access VB Code Needed (more)


Ok I have a checkbox (cbxCltRespon) with the question:

Is the Responsible Party Different then the Client?  If they Check it (yes)
then the sfrmContResp form will pop-up, if then don't check it then I want
it to populate the txtCltResponName field with the First and Last name of
the Client.  Did I do the Code Correctly??



Private Sub cbxCltRespon_AfterUpdate()
If Me.cbxCltRespon.Value = True Then
        DoCmd.OpenForm "sfrmContactResponParty"
    Else
            txtCltResponName = "txtCltFName" & "txtCltLName"
    End If

End Sub

Also the next Field is a checkbox also that asks if the Contact is the same
as the Responsible Party... If it is then populate the txtConName Field with
the name in the txtCltResponName unless that has been populated with the
Client Name above, please tell me if I wrote this code correctly also:
(note, The Responsible party can be the Client or somebody different.... The
Contact Name Can be the Responsible Party if the responsible Party is not
the Client)

Private Sub cbxContRespon_AfterUpdate()

If Me.cbxContRespon.Value = True And Me.cbxCltRespon = True Then

'(Saying the Contact Name=Responsible Name) and the (Responsible Party is
Different from the Client Name)

        txtCltContactName = txtCltResponName
    Else
'(Saying the Contact Name=Responsible Name but they did NOT check that the
Responsible party was different from the Client)

        Me.cbxContRespon.Value = True And Me.cbxCltRespon = False

'Can I make this msg be two lines?

        MsgBox "You have stated that the Responsible party is the client" &
_
              "The Contact Name MUST be different"
    Else
        Me.cbxContRespon.Value = False
        DoCmd.OpenForm "sfrmContactResponParty"

    End If
End Sub



*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also
allow you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation
with instructions.  Once you are a member of the files group, you can go
here to upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************


*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: