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

Record counter problem

Status
Not open for further replies.

ninash

Technical User
Jul 6, 2001
163
GB
Hi all
I have a Access database that is linked to an SQL database.

Due to something I suspect to do with SQL I have the following problem

The auto counter field does not push on to the next number unless you move onto a new record.

Problem
In the form is a button the user can push to add an invoice address. If they push this button the auto counter field is not filled in and no link is formed.

How do I force the auto number field to complete if the user press's this button

Thanks for any help you can give
Tony
 
How are ya ninash . . . . .

[blue]The auto counter field does not push on to the next number unless you move onto a new record.[/blue]
[blue]Actually, the autonumber doesn't show until you edit a new record[/blue] (by entering input from the keyboard). When you enter data from the keyboard, this puts the record in edit mode (as depicted by the pencil icon). [purple]Edit Mode triggers autonumber if its a new record.[/purple]

Your problem is that [purple]writing to controls thru VBA does not trigger edit mode![/purple] To fix this, in your code add the following line, after the line that writes the address:
Code:
[blue]Me.Dirty = True[/blue]

Calvin.gif
See Ya! . . . . . .
 
Hi AceMan1

I tried to get your one liner to work and I am unsure if it was where I was placing it or just not understanding if it needed to be attached to a field.

However after a good nights tossing and turning with this problem rushing through my head I tried refreshing the form (something I should have tried) and the problem seems to have gone away.

if you could explain how to use the dirty command I would be interested in finding the correct way of using it.

Thanks for the speed of your reply

Tony
 
Setting the forms .dirty property to false, is one of several ways of refreshing/saving the current record of the form. It is probably one of the more reliable working with mdbs, see this article by Allen Browne Losing data when you close a form. I don't know, however, what's best when using SQL server.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top