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

create random rows in table

Status
Not open for further replies.

patrysib

Programmer
Oct 21, 2007
23
RO
I have only a table. I put in a tab control, a subform with a form view at that table and a subform with a dtasheet view. when I insert a row in the first subform, it apears not a the begin of the table enad not at the end, but in random position.
I have to buttons: add, save:
the name of the first subform is baza and the name of the form in datasheet view is table1sf.

Private Sub add_Click()
On Error GoTo Err_add_Click

Me!baza.SetFocus 'Set the focus to the 1st subform
Me!baza.Form![cnp].SetFocus 'Set the focus to the subForm primary key field


DoCmd.GoToRecord , , acNewRec

Exit_add_Click:
Exit Sub

Err_add_Click:
MsgBox Err.Description
Resume Exit_add_Click
End Sub

Private Sub save_Click()
On Error GoTo Err_save_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
[Table1sf].Requery
Exit_save_Click:
Exit Sub

Err_salveaza_Click:
MsgBox Err.Description
Resume Exit_save_Click
End Sub
 
A record will be put in the correct place according to the sort order. Check the sort order for the problem form.
 
That's how most databases work, there's no concept of "first" or "last" record. When your SQL statement is simply

SELECT * FROM MyTable

records will not necessarily displayed in order reflecting when they were added. You need to add a SORT BY clause to have it list in any particular order.

 
Did I just say "SORT BY"???

Yikes, must have had a PICK flashback.

I meant "ORDER BY".


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top