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

Inserting a Record into a database

Status
Not open for further replies.

qed2

Programmer
Feb 17, 2000
1
US
I have a form with some bound text boxes. After the operator enters some code (Cycle current record) the program waits for an F9 key and then tries to create a new record with only some of the values of the first record in TABLE AAAA using <br>

<br>

INSERT INTO AAAA VALUES (field1,field2,field3)<br>

<br>

The record pointer won't move. It stays on record 1. I want it to move to record 2 so they can enter information into record 2. And then record 3 etc. Any ideas ?? I used Move last , moveforst accommand, aclast all to no avail
 
Ok spill out your code<br>
Can't give an answer on 5 words. <p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Am I missing something? Wouldn't you want to cycle all records? <p>jgarnick<br><a href=mailto:jgarnick@aol.com>jgarnick@aol.com</a><br><a href= > </a><br>
 
Try adding this code to the code that runs when the F9 key is hit:<br>
<br>
DoCmd.GoToRecord acDataForm, &quot;frmTest&quot;, acNewRec<br>
<br>
Substitute the name of your form where I have &quot;frmTest&quot; (the quotes are mandatory). This should move you to a new record. This should work with Access97...don't know about earlier versions.
 
I'm assuming that your INSERT is working correctly.<br>
<br>
You just want the form to DISPLAY the newly created row.<br>
<br>
Try adding this code AFTER the INSERT statement:<br>
<br>
Me.Requery<br>
<br>
Dim db As DATABASE<br>
Dim rs As Recordset<br>
<br>
Set db = CurrentDb<br>
Set rs = Me.RecordsetClone<br>
<br>
rs.MoveLast<br>
<br>
Me.Bookmark = rs.Bookmark<br>
<br>
rs.Close<br>
db.Close<br>
<br>
Set rs = Nothing<br>
Set db = Nothing<br>
<br>
<p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
 
Sorry all. After reading Jim's reply, I realized I'd not read the original request carefully enough. My suggestion would do nothing more than move the user to a new, empty record. I was too quick on the draw!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top