Forms - combo box

  • Thread starter Thread starter bhapi148
  • Start date Start date
B

bhapi148

Guest
I have a database that allows users to view or add records using a form. My problem is when I open the form, there is already data in all my fields (this is the first record). Is there a way to open the form with no records showing, just blank fields? I want users to select from a combo box what data to view. I have changed the Form properties to Date Entry, but this does not all me to view corresponding data once I have selected data from the combo box. I hope you can understand what I am trying to do. Any suggestions, greatly appreciated. Thanks.
 
U could just add a
docmd.GoToRecord acDataForm,,acNewRec
on the forms startup event.

So when they open the form, it will start at a new record. Then when they choose an item from the combo it will take them to that record.
 
docmd.GoToRecord acDataForm,,acNewRec



Thanks for your prompt reply. I am not too good with code. Not sure where I need to enter the information you gave me. Can you please direct me.
Also, could you please explain the event. I understand the [docmd.GoToRecord and acNewRec] but don't really understand accDataForm. thanks.
 
Sorry, i got that wrong anyway...

If you don't know much about code, the easiest way would be to use a macro.

Open up your form in design mode, and select properties from the view menu. In the Event tab in the properties window, look for the event 'On Open". When u click in this area u should see three ... 's on the right hand side. If u click that a dialog should popup asking if u want to use Expression builder, Macro Builder, or Code builder... Select Macro builder and click OK.

Give your macro a name, and under the action drop down, choose 'Goto Record'. Then look down the bottom and after record it should say 'Next'. Change this to 'New'.

Click save and close the macro window. Then open your form and see if it worked.


If u wanted to do it in code, instead of selecting Macro builder, choose Code builder, and that will open up Microsoft Visual Basic's Code editor. And u should see something like this:
Code:
Private Sub Form_Open(Cancel As Integer)

End Sub

Then just enter DoCmd.GoToRecord , , acNewRec in between the two lines so u then have this:
Code:
Private Sub Form_Open(Cancel As Integer)
    DoCmd.GoToRecord , , acNewRec
End Sub

Hope that's not too confusing...
 
And if u want to know more about gotorecord, look up 'GoToRecord action' in Microsoft Access Help.

It explains it much better then i could, lol. :D
 
Thanking you very muchfor all your trobule. You don't know much time I have spent on this. That's exactly what I want it to do. Forgot all about macros. Thanks.
 

Users who are viewing this thread

Back
Top Bottom