Set a table value

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
 
R

rbeach

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
 
P

Piet Linden

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
 
R

rbeach

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top