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

Accessing a current record using a form

Status
Not open for further replies.

ESTAGroup

Technical User
Aug 12, 2004
53
US
Hi All,

I'm using a form to enter data into a table. Very simple. But how do I allow the user to bring up a previous record so it can be edited and then saved back to the database as the same record but with new information? When I type in an old record, it tries to create a new record and then gives me a key error.

Thanks,

Gregg
 
How are ya surferboy30 . . . . .

Normally this is one of the easiest things to do. [blue]It sounds as if you have some code running somewhere.[/blue]
surferboy30 said:
[blue]When I type in an old record, it tries to create a new record and then gives me a key error.[/blue]
[purple]Be more specific about this . . . . .[/purple]

Calvin.gif
See Ya! . . . . . .
 
For instance, my primary key is the "Order_No" field and I enter details for order 12345 and then commit the record to the database. I then try to recall that record by entering 12345 in the order field on my form and it tries to create a new record with this same order number rather than bringing up the recod that resides in the database. This creates a primary key error.

Hope that helps.

Gregg
 
I would advice on not using the same control for both entering data and performing a search, it has a tendency of creating such headaches;-). Use for instance a combobox for the search (use the wizard to create it, third option "Find a record on..."), and leave the order_no control for entering/altering data.

Roy-Vidar
 
surferboy30 . . . . . .

Not only is [blue]RoyVidar[/blue] correct, but [blue]your saying you can't navigate through previously saved records![/blue]

[purple]Is this a bound or unbound Form?[/purple]

Calvin.gif
See Ya! . . . . . .
 
And what is the value of the DataEntry property of the form ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I tried the combo box and received this error:

Run-time error '3021'
No current record

I see the record number in the drop-down though. I have all "Allows" under the Data tab set to YES. The form has a record source so I assume it is bound. I am fairly new to using forms as you can see.

Gregg
 
surferboy30 . . . . .

Answer [blue]PHVs[/blue] question! . . . Its important . . . .

Calvin.gif
See Ya! . . . . . .
 
Try 'No'

Point is, when set to yes, the only records available in the form, are new records, when trying to find one of the old records, Access can't find them -> no current record.

Roy-Vidar
 
YES! That was it. Excellent. Thank you so mnuch for your help.

Gregg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top