April- To create a global variable that is available to all the subs and functions in your form module, on the very top of the form modules code there is 'Option Compare Database', add a global variable under that line. like: Option Compare Database Option Explicit Dim strVariable As String strVariable is now available to all the code in that module. Global variables like this are usually set in the 'Onload' event of the form. You can also work with them from other forms and modules. Be cautious using globals. If you have many forms, you might create globals with the same name, Access does not like this. -Anthony -----Original Message----- From: April Pace [mailto:4office@xxxxxxxxxxxxx] Sent: Sunday, January 05, 2003 4:23 PM To: Office (E-mail) Subject: [mso] Access VC setting Variables Help...... If you have been following my posting I have a form that if they click on a button it will open another form.... I have a Client Info Form Mailing Address Billing Address Contact/Responsible Party Form The Contact & Responsible person and be one and the same or two different persons... Since it can be one and the same I have both on one form.... Ok, so here is what I have done and am trying to do: If they click that they need to add an Responsible Party, I have figured out how to get what ever name they put on the Contact/Responsible Form to populate my main form (which is still open) in the ResponsibleName field. Now if they specify that the contact name is the same as the Responsible Party Name, then it will automatically populate the Contact Name field with the same name was the Responsible Party Name field.... But if they specify that the Contact name is DIFFERENT from the Responsible Party's Name then the Contact/Responsible Form will re open so they can add the Contact Name.... Ok here is what I need to figure out..... I want to create a variable on my main form tblClientInfo at the place where it calls the Contact/Respon Form to open... I want the variable WhoCalledForm where I can say WhoCalledPartyForm="Responsible" or WhoCalledForm="Contact" Then on the tblContact/Responsible I want to do the following: Private Sub CommandClose_Click() On Error GoTo Err_CommandClose_Click If WhoCalledForm = "Responsible" Then Me.txtCltResponName.SetFocus 'set the focus on the form to Me.txtCltResponName Forms!frmClientInfo.txtCltResponName = Me.txtCltResponName 'set the value of Me.txtCltResponName ElseIf WhoCalledForm = "Contact" Then Me.txtCltResponName.SetFocus Forms!frmClientInfo.txtCltContactName = Me.txtCltResponName End If DoCmd.Close Exit_CommandClose_Click: Exit Sub Err_CommandClose_Click: MsgBox Err.Description Resume Exit_CommandClose_Click End Sub I tried on the Main Form Dim WhoCalledForm as String, I also tried Public WhoCalledForm as string (But after the Private Sub cbxContRespon_Click() ) and the other form could not see the variable.... How do I (Or were) do I state a "public" Variable so that the code above will work April ************************************************************* 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 *************************************************************