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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy last entry in a table

Status
Not open for further replies.

Daina

Technical User
Dec 5, 2001
14
AU
Hi,

I am fairly new to access and am having trouble writing an expression for the default value in my field properties,

I have a field name: Batch Number and I need to have this default to the last number entered until a new number is entered I have tried the following but I am afraid it was written for something else and I do not know how to adapt it to fit my needs or if it is the correct one I need to use.

Please help getting desperate..

Type RecItems
Field1 As String
Field2 As String
Field3 As String
End Type
Dim mRecItems As RecItems

Before_Update
mRecItems.Field1 = Me.txtField1
mRecItems.Field2 = Me.txtField2
mRecItems.Field3 = Me.txtField3
End Sub

On_Current
Me.txtField1 = mRecItems.Field1
Me.txtField2 = mRecItems.Field2
Me.txtField3 = mRecItems.Field3
End Sub
 
If by the last number entered you mean the highest number you could use Dmax to look up the number.

You could also create a Top Ten Query and set it only return the highest number ie. a top one query. That value could be used as a default. Select the dropdown box in the query design view (it should say All) and type in a 1.

Both option could then be used with a SetValue macro.

If it is not the highest number let us know and we can come up with other options

Regards

Neil Berryman
IT Trainer
neil_berryman@btopenworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top