VBA question..

P

pointies

am trying to populate some fields in Access depending on what the user
puts in. To keep the example clear, I have a Message Box (MessHist), A
Text Box (Textbox), a Combo Box (NewAssign) and a Check Box (Check44).

When a button is pressed, it first makes

MessHist = MessHist & Textbox

then check if NewAssign is a new value
If yes, assign new value, attach message to MessHist, if no, leave
Messhist alone

Then check if checkbox is checked
If yes, assign new value, attach message to MessHist, if no, leave
MessHist alone.

Here is the code I have .. the problem I run into is when I have a new
value in NewAssign AND the checkbox checked. The two messaged are not
being generated. But it works fine if either the NewAssign value
changed or Checkbox is checked. any help would be greatly appreciated

Private Sub BtnSbmt2_Click()

Dim Temp As String
Dim IDstamp As String
Dim Timestamp As String

Timestamp = Date & " " & Time()
IDstamp = DLookup("[FirstName] & ' ' & [LastName]", "Contacts", "[ID] =
" & [OpenedBy])

MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp & vbCrLf & "
" & Textbox & vbCrLf

If NewAssign <> AssignedTo Then
AssignedTo = NewAssign
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp & vbCrLf & "
" & Textbox & vbCrLf & vbCrLf & Timestamp & " *** Message Re-assigned
to " & DLookup("[FirstName] & ' ' & [LastName]", "Contacts", "[ID] = "
& [AssignedTo]) & " ***" & vbCrLf
Else
If Check44.Value = True Then
Status = "Closed"
MessHist = MessHist & vbCrLf & Timestamp & " - " & IDstamp & vbCrLf & "
" & Textbox & vbCrLf & Timestamp & " *** Message Closed by " & IDstamp
& " ***" & vbCrLf
End If
End If

Textbox.Value = Null
Me.Refresh

End Sub
 
S

SteveS

Check44 is evaluated only when NewAssign <> AssignedTo.

As written, your logic is

If NewAssign <> AssignedTo Then
.(statements)
 

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