Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Appending to New Record, Not to Same Record

Status
Not open for further replies.

StarScream

Technical User
Oct 10, 2001
46
US

I have a simple log form with a bounded text box and an unbounded text box. The user enters text into the unbounded box and when presses a button/exits field, the information is added to the bounded box.

While this works -- I was surprised to find that the info is all in one field(record) and not added as consecutive records.

Here's the code on the unbounded text box:
Code:
Private Sub Text0_Exit(Cancel As Integer)
If Me![Text0] <> "" Then
    Me![Note] = Time() & " -- " & Text0 & "  [" & Environ$("username") & " -- " & Date & "]" & vbCrLf & vbCrLf & Me![Note]
    Me![Text0] = ""
    Me![Note].Requery
Else
    End If
End Sub

What I'd like to do is have the unbounded text box add the data to a new record and have the bounded text box show all the records like a running log. I tried playing around with making it a continuous subform, but that doesn't look anything close to what I need it to.

My thought would be to try swapping the two types of boxes: the user input box would be bounded and would need to not show the record indicators/buttons. The display box would then be unbounded and would have code that would display the string summation of all records.

Anyone think this would work?
 
StarScream

I think there are two issues you need to think about:
1. If you want multiple records to appear on one form you need either continuous forms or you can base a list box on a table, and set the record source equal to tblYourTabl!Note That will give you a list of all the notes.

2. To get to a new record, you can either insert a DoCmd.RunCommand acCmdGotoRecordNew statement before you update the list box, or you can run a simple append query that appends the value of the unbound box to a new record in the table. You can run the query with the DoCmd.OpenQuery command.

Let me know if either of these is a solution for you.

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top