Can't Save Record and Requery

  • Thread starter Thread starter Lori
  • Start date Start date
L

Lori

I've got a couple things going on. I've created a form that launches from a
button so I can add a new record while inputing data. It as a Save and Close
coded into the "on close" property. It will also requery the combo box so
that I can then select the new data. All was working fine until...

I added the dropdown command on the "on enter" property of the combo box.

Now I get a debug error on the Save/Close. I click "end" try the save/close
button again and it works. Any idea why the initial problem though?

~Lori
 
June7,

This is the code for the launched data entry form's Save/Close button:

Private Sub cmd_SaveClsNewSpeaker_Click()
DoCmd.Save
DoCmd.Close
End Sub

This is the code for the launched data entry form's "On Unload" property:

Private Sub Form_Unload(Cancel As Integer)
[Forms]![f_Quotes]![cmb_Speaker].Requery
End Sub

These worked fine until I added this to the main form's combo box:

Private Sub cmb_Speaker_Enter()
Me!cmb_Speaker.Dropdown
End Sub

This automatically causes the combo box to drop down so that when I type I
can see what items follow.

Now when I click on the launched form's Save/Close button, it gives me a
debug error, I click 'debug' and it wants me to debug the initial 'save' line
above. I click 'end' and then try the button again and it works.
 
June,

Well beat that. I just tried it again, without making any changes and it's
working now....

Thanks for offering though.

Lori

Lori said:
June7,

This is the code for the launched data entry form's Save/Close button:

Private Sub cmd_SaveClsNewSpeaker_Click()
DoCmd.Save
DoCmd.Close
End Sub

This is the code for the launched data entry form's "On Unload" property:

Private Sub Form_Unload(Cancel As Integer)
[Forms]![f_Quotes]![cmb_Speaker].Requery
End Sub

These worked fine until I added this to the main form's combo box:

Private Sub cmb_Speaker_Enter()
Me!cmb_Speaker.Dropdown
End Sub

This automatically causes the combo box to drop down so that when I type I
can see what items follow.

Now when I click on the launched form's Save/Close button, it gives me a
debug error, I click 'debug' and it wants me to debug the initial 'save' line
above. I click 'end' and then try the button again and it works.


June7 via AccessMonster.com said:
Don't get what you mean by 'dropdown command'. Could you show actual code?
What is the exact message of debug error?
 
June7 via AccessMonster.com said:
Congrats! Just one suggestion. When you refer to controls in code use Me.
(with the dot) instead of Me! (with the 'bang'). With the dot you should
get
intellisense tips, if you have the correct Reference Library selected,
which
I believe is Microsoft ActiveX Data Objects x.x Library.

You don't need a reference to ADO (nor to DAO) to get intellisense on Me.
The properties and controls of the form are available regardless of the
references.

It's not wrong to use the bang for controls, but you're right that you get
intellisense only if you use the dot.
And I was taught to
use the bang to refer to fields of recordset compiled with SQL SELECT
queries
in VBA.

Technically, the bang is used to denote members of a collection, such as a
recordset's Fields collection or a form's Controls collection. The dot is
used to denote properties or methods of an object. You can use dot
(usually) to refer to controls on a form because Access makes those controls
available as properties of the form (while they remain members of the form's
Controls collection). It does the same with the fields of the form's
recordset.

The only time you can't use the dot for a control or field is when it has
the same name as one of the form's built-in properties or methods. Then you
must use the bang.
 
Back
Top