Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pop-up Form Return Value

Status
Not open for further replies.

jcmv007

Technical User
Nov 1, 2001
88
US
Using WindowsXP SP1 AND ACCESS2002 SP1.

I have a Logon form which opens as the first form of my app., after the User enters his login Id and Password and presses the OK button. I have created a Pop-up form that opens an agreement form where the user has to agree or disagree with the terms and conditions stated. How do I get the answer the user selected back in my Logon form so I know wether to open the app. or close it.

The form names are: frmLogon and frmAgree.

Thanks,
 
Create a module that defines variable(s) as public. Public variables can be used throughout your application, and the value set in one form (or report) is carried to other forms, even if the first form has been closed.

So set a public variable equal to the response to your agreement question. Then when you go back to your logon form the value will be available.

This is also a good way to carry the userID, security level, etc., throughout your application so you can control what buttons/forms/etc. are available based on that user's security level and also so you can record the user's ID on records where you want to know the last user who changed the record.

But why don't you immediately exit the user from the application when he does not accept the agreement?
 
BSman,

Thanks for the prompt response, is it posible provide some sample code to get me started. I have improved in my understanding of VBA but, still have long ways to go.

Exit the user if he does not agree is a great idea.

Thanks again.


JAMES
 
The module is simple:

Public strUserID as String ' to store userid
Public strSecurityLevel as String
Public lngResponse as Long ' store response to question



In your frmLogon, as part of the code for the OK button, set strUserID and strSecurityLevel to those values (if you don't have security level defined somewhere, then skip that).

In your frmAgree, in the afterUpdate code for whatever control contains the user's response to the agreement (I'll call it txtAgree), put the following code:

lngResponse = me.txtAgree

Although I'd really suggest just doing the following. I'm assuming that the value in txtAgree is an integer, otherwise use string/text variables. Let's say that a value of 1 means agreement, any other value is non-agreeement:

if me.txtAgree = 1 then
' close the agreement form and open the application menu
docmd.close
docmd.OpenForm "frmMainMenu"
else
' exit Access
docmd.Quit
end if
 
BSman

Thanks for your help I finally solved it doing the following.

I called the agreement form from the logon form and from there depending on the user's selection the app continued or closed.

Here is the code:
Code:
Private Sub cmdCancel_Click()
On Error GoTo Err_cmdCancel_Click
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qappDBAcessLog"
    DoCmd.OpenQuery "qdelCurrentUser"
    DoCmd.OpenQuery "qdelDatosDeGastos"
    DoCmd.SetWarnings True
    Call CloseAllFormsButOne
    
    DoCmd.Quit


Exit_cmdCancel_Click:
    Exit Sub

Err_cmdCancel_Click:
    MsgBox Err.Description
    Resume Exit_cmdCancel_Click
    
End Sub
Private Sub cmdOk_Click()
On Error GoTo Err_cmdOk_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmSwitchBoard"
    If Me.fraOpcionesAcuerdo = 1 Then
    
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qupdAcuerdo"  'actualiza tabla indicando usuario acepto
    DoCmd.SetWarnings True
    
    DoCmd.Close
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    End If
    
Exit_cmdOk_Click:
    Exit Sub

Err_cmdOk_Click:
    MsgBox Err.Description
    Resume Exit_cmdOk_Click
    
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top