Forms and Appending Data

  • Thread starter Thread starter The Boondock Saint
  • Start date Start date
T

The Boondock Saint

Hello Everyone.

Im wondering if anyone has any thoughts on how to do the following

I have a form which has a time variable in it. (it is displayed as a label)
the record that is being displayed also autosaves every 10 secs

What id like to be able to do... is be able to have a textfield.... where i
can write in a message..... and it will add it into the database.... along
with the time variable....

for example.. if the time was 10:45 and i typed in..... "oh its getting
late"
then it would add something like

10:45 - "oh its getting late" into the database.... on top of the other
messages

for example if at say 9:05 i had typed in "i feel like a beer" then the
result would look like...

10:45 - "oh its getting late"
09:05 - "i feel like a beer"

Can it be done... and would i have to put it on a differant form.....
because if im half way through typing.. and the 10 sec autosave kicks in...
it would only save parts of my messages....

Any ideas? Any help would be awesome..
Cheers
The Saint
 
I'd just run another append query.

Add an unbound textbox, called txtMessage, to the form. Then in the Timer
event, add code like this:
Private Sub Form_Timer()
Dim sSQL As String

'You're existing code would go here.

'Add the new code - only if the user is not currently
'writing something into the TextBox, and even then
'only if there's something to write to the database.
If Screen.ActiveControl.Name <> "txtMessage" _
And Len(Trim(Me.txtMessage)) > 0 Then

sSQL = "UPDATE tblSomeTable SET Message = """ & _
Me.txtMessage & vbCrLr & """ Message " & _
"WHERE x = y"

'Amend the above query to suit your requirements.
'Since you're doing some query stuff earlier, you will
'probably be able to use variable declared for that
'purpose.

DBEngine(0)(0).Execute sSQL As String
End If
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Canberra, Australia
 

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

Back
Top