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!

Resetting incremental number on subform

Status
Not open for further replies.

Janatwork

Programmer
Dec 16, 2003
22
GB
Hi,
Can anybody help please. I'm sure this is quite straight forward, but I have searched through the site and can't find anything that quite matches my query and I'm no good with VB
So here goes,

I have two forms, one being a subform into which Sales Order data will be entered. What I want the user to be able to do is to keep looping through the subform adding detail lines until the order is complete.
I need the line number on the subform to increment by one each time the user selects 'add more order lines' and then to reset on 'add new order'.
I tried using Dmax which works, but I don't know how to reset the line number on a new sales order.

Any help would be appreciated and it will save me another day of searching.............[ponder]
 
How are ya Janatwork . . . .
Janatwork said:
[blue]and then to reset on '[purple]add new order[/purple]'.[/blue]
When you [purple]add new order[/purple], [blue]are you switching to a new record[/blue] on the MainForm?

If so then in the [blue]On Current[/blue] event of the mainform, copy/paste the following ([blue]you![/blue] substitute proper names in [purple]purple[/purple]):
Code:
[blue]   Dim prp As Property
   
   Set sfrm = Me![purple][b]subFormName[/b][/purple].Form![purple][b]LineNo[/b][/purple].Properties("DefaultValue")
   
   If Me.NewRecord Then
      prp = 1
   Else
      prp=DMax( . . .) + 1
   End If
   
   Set sfrm = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .
 
Hi TheAceman1,

Thanks for taking the time, I will copy and paste as you suggest into my DB and see how it goes. I'll let you know the result.
[bigsmile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top