Set a table value

  • Thread starter Thread starter rbeach
  • Start date Start date
R

rbeach

I am not a programmer, but I need to set a value in a table automatically
when a form is opened. This will toggle from Yes to No each time the form is
opened. Below is the code I currently have in place. I am sure this only sets
the variable, not the table value. Please let me know what I need in place.

Private Sub Form_Open(Cancel As Integer)

Dim fLogout As Boolean

fLogout = DLookup("[LogOutUser]", "[LogoutTable]")

If fLogout = True Then
fLogout = False
Else
fLogout = True
End If

End Sub
 
I have written the line:

CurrentDb.Execute "UPDATE LogoutTable SET [LogOutUser]=False"

and

CurrentDb.Execute "UPDATE LogoutTable SET [LogOutUser]=False"

in the code and it works.

Thanks anyhow
 
I am not a programmer, but I need to set a value in a table automatically
when a form is opened. This will toggle from Yes to No each time the formis
opened. Below is the code I currently have in place. I am sure this only sets
the variable, not the table value. Please let me know what I need in place.

Private Sub Form_Open(Cancel As Integer)

   Dim fLogout As Boolean

   fLogout = DLookup("[LogOutUser]", "[LogoutTable]")

   If fLogout = True Then
   fLogout = False
   Else
   fLogout = True
   End If

End Sub

why not just
fLogout = Not fLogout?

and then
DBEngine(0)(0).Execute "UPDATE LogoutTable SET LogoutTime =Now WHERE
LogonId='" & fOSUserName &"'",dbFailOnError

to do the Update
 
Simplicity at it's best.

Thank You
--
Rick


Piet Linden said:
I am not a programmer, but I need to set a value in a table automatically
when a form is opened. This will toggle from Yes to No each time the form is
opened. Below is the code I currently have in place. I am sure this only sets
the variable, not the table value. Please let me know what I need in place.

Private Sub Form_Open(Cancel As Integer)

Dim fLogout As Boolean

fLogout = DLookup("[LogOutUser]", "[LogoutTable]")

If fLogout = True Then
fLogout = False
Else
fLogout = True
End If

End Sub

why not just
fLogout = Not fLogout?

and then
DBEngine(0)(0).Execute "UPDATE LogoutTable SET LogoutTime =Now WHERE
LogonId='" & fOSUserName &"'",dbFailOnError

to do the Update
 
Back
Top