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

Autonumber incrementing after updating fields?

Status
Not open for further replies.

gdev

Technical User
Joined
Mar 12, 2001
Messages
38
Hi Everyone,

How I can make an autonumber increment after
dlookup does it thing to make sure there isn't a record matching the new entries?

As soon as I select the plan, autonumber increments which makes the if statement always true. I don't want autonumber to increment until after dlookup checks for matching records.

Or is there a better way to do this?

If (Not IsNull(DLookup("[CostCenterid]", "tCostCenter", "[costcentercode] ='" & [costcentercode] & "'" & "And [costCenterRegion] = '" & [costCenterRegion] & "'" & "And [planid] = " & [planId]))) Then
MsgBox "stop", vbOKOnly
Me.BusinessContactName.Enabled = False
Me.ControllingContactName.Enabled = False
Me.costCenterType = False
Else
Me.BusinessContactName.Enabled = True
Me.ControllingContactName.Enabled = True
Me.costCenterType.Enabled = True
End If

Thanks
Gwen
 
Hi Gwen

The autonumber is assigned / created with the OnInsert event -- as soon as Access "sees" any entry for a bound control (a control field on the form that is linked to the source table or query), it creates the number.

The work around would be to do your testing with an unbound control field. Then determine to proceed or not.

For example, use an unbound combo box to select "the plan"

Having said that, you may wish to review...
Why AutoNumber shouldn't be used in MultiUser databases (And How to ge the Unique Number) faq700-184

Richard
 
How are ya gdev . . . . .

[blue]Willir[/blue] is correct. No matter how you do it, you have to write to the new record ([purple]put the record in edit mode . . .[/purple] depicted by the pencil icon). Write to a control thru VBA.

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top