By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,787 Members | 2,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,787 IT Pros & Developers. It's quick & easy.

Loading "First" Record In form

P: 13
I have a Database form in Single View for users to look-up and/or enter data. When the form loads the combo box is empty, which I like - but the fields in the form are all filled in with what the database sees as the "first" record - which is alphabetically not the first, but is as to the ID field. All that said, I would like the fields to either fill in with the alphabetical first record, or merely blank. I found the code to have it load New - but I don't want a New record because often it is merely opened to look-up data, not enter.
Here is my form load code. Any additional code would be most appreciated.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. DoCmd.Maximize
  4. ' Turn the MouseWheel Off
  5. Dim blRet As Boolean
  6. ' Call our MouseHook function in the MouseHook dll.
  7. ' Please note the Optional GlobalHook BOOLEAN parameter
  8. ' Several developers asked for the MouseHook to be able to work with
  9. ' multiple instances of Access. In order to accomodate this request I
  10. ' have modified the function to allow the caller to
  11. ' specify a thread specific(this current instance of Access only) or
  12. ' a global(all applications) MouseWheel Hook.
  13. ' Only use the GlobalHook if you will be running multiple instances of Access!
  14. blRet = MouseWheelOFF(False)
  16. ' Change the Caption on the form
  17. Me.Caption = "Reading Leaders and Student Readers"
  19. ' Enable the lookup combo
  20. Combo114.Enabled = True
  23. ' Show the edit button
  24. cmdEdit.Visible = True
  26. ' Show the New button
  27. New_Button.Visible = True
  29. ' Show the Exit button
  30. cmdExit.Visible = True
  33. ' Hide the OK button
  34. cmdOK.Visible = False
  36. ' Hide the Cancel Button
  37. cmdCancel.Visible = False
  39. 'Hide the Delete Button
  40. cmdDelete.Visible = False
  45. End Sub
Mar 27 '08 #1
Share this Question
Share on Google+
1 Reply

P: 19
If you want it to be alphabetical, simply add a sort to the underlying query of your form.

Using a bound form like this, you could "clear" everything on startup by setting the default value of your UNBOUND combobox to this:


then, bind your primary field in your recordset (in the underlying querygrid) to the combobox. When the form opens, the combo box will be set to nothing, and so will the form.

To make items show up, put the following code in the "after update" event of the combobox:
Mar 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.