Question : Public variable value missing

I've a Module in Access where I declare the following variables:

Public Turno, Empregado As String
Public Data As Date

On frmConfig I assign values to the variables as follows:

Empregado = cboChefeEquipa.Value
Data = Calendar2.Value
Turno="M"

I then close frmConfig and open frmOcorrencias. On that form I want to do something like this:

Sub Form_Load()
    txtTurno.Value = Turno
    txtData.Value = Data
    txtEmpregado.Value = Empregado
End Sub

The problem is that when I do this, the variables are empty!

Where is the mistake?

Thanks.

Answer : Public variable value missing

your variables are NOT losing their value when your second form opens

Change your line of code to open the frmPrincipal back to this

DoCmd.OpenForm "frmPrincipal "

You were getting an error because I was assuming that the values you were trying to pass were field names, not variables.

Now that you've changed that, your code is working as you explained. I didn't change anything else.

J



Random Solutions  
 
programming4us programming4us