Click to See Complete Forum and Search --> : Updating one form field to another form field


ladysnake38
12-21-2007, 11:11 AM
Hi:

I have a database where the users enter the data via a main form (frmntwnar). In that form is a field CurrNotes where if they need to enter a new status entry, they push a button (add new status) which opens a second form (fmrhiststat) and the new entry is added. Upon pushing the close button in the second form the following code is run.

The purpose is to update the second forms table (which it does), clear the main forms CurrNotes field (which it does) and take the most record entry from the second form (frmhiststat) HSCurrNotes field and update the entry into the main frm (frmntwnar) CurrNotes field (which right now is blank and not displaying the current entry).

The tblhiststa has numerous HSCurrNotes entries and I'm only trying to pull the lastest entry for each activity. The unique identifer between the two forms is ID and they are linked on that.

Any suggestions? I'm at my wits end on this one.

Cheryl

'Before the close, take the most current record and place it into the NAR form
'under Last Status

Dim OldStatus As String
Dim NARCurrNotes As String


Form_frmntwnar!CurrNotes = OldStatus



If LastDateUp = Date$ Then
Form_frmhiststat!HSCurrNotes = NARCurrNotes
OldStatus = Chr(10)
OldStatus = DLast("[tblhiststat]![HSCurrNotes].[]")


End If

DoCmd.CLOSE

Exit_Close_Histstat_Form_Click:
Exit Sub

bluestartech
12-22-2007, 08:58 AM
your code is a little obscure, but in terms of sql, if you want to get the last posted entry, something like as follows:

select currNotes from table_name order by notes_id desc limit 1;

this will order the results in descending order and limit 1 will pop off the latest entry made