Previous value

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

Ok. for the last 6 hours at least I have been banging my
head into the wall over this stupid little problem.

I have a textbox that is not auto number, I then have two
dropdown boxes that are populated by a table and a query.
Heres the problem All I want to happen is when I go to a
new record I want it to Save the values from the old
record in those fields and auto count the first field. I
have tried SQL querys that call the info from the last
record and increase the number by one but the problem is
that I cannot then get that info into the stupid combo
boxes and the text box after going to a new record. I have
tried to set those values at the default values and I get
#name? instead of an actual value So is there any easy way
to just grab and put info from the last record?
I know in file makerpro there was a Lag option for
controls like you could lag one or two records back as a
default value for a control.
 
Use the BeforeInsert event procedure of the subform to insert the next
number.

Imagine the main form is entering CD albums, and the subform is entering the
tracks on the album. You want the next available track number for the cd
when you begin entering a new track. The code for the subform's BeforeUpdate
event procedure would be something like this:

Private Sub Form_BeforeInsert(Cancel As Integer)
Dim strWhere As String

With Me.Parent
If .NewRecord Then
MsgBox "Select a record in the main form first."
Cancel = True
Else
strWhere = "AlbumID = " & !AlbumID
Me.TrackID = Nz(DMax("TrackID", "tblTrack", strWhere), 0) + 1
End If
End With
End Sub
 
Back
Top