Created MDE, Doesn't Like my Code?

D

Dave Elliott

This code runs on the main forms drop down list for a customer, after
update.
After choosing a customer, then the list of clients for that customer would
be available.
It is necessary for it to run or else the client list will not be seen
correctly for the customer chosen.
Alternativley, I would have to save the record manually, then requery the
client list!
Here is my code, but after creating a mde, it errors out.
It says the command or action save isnt available now.
Is there anything else I can do?

DoCmd.RunCommand acCmdSave
Me.[Client ID].Requery
If err <> 2501 Then
MsgBox "Contact Tech Support"
End If
 
R

Rick Brandt

Dave Elliott said:
This code runs on the main forms drop down list for a customer, after
update.
After choosing a customer, then the list of clients for that customer would
be available.
It is necessary for it to run or else the client list will not be seen
correctly for the customer chosen.
Alternativley, I would have to save the record manually, then requery the
client list!
Here is my code, but after creating a mde, it errors out.
It says the command or action save isnt available now.
Is there anything else I can do?

DoCmd.RunCommand acCmdSave
Me.[Client ID].Requery
If err <> 2501 Then
MsgBox "Contact Tech Support"
End If

The acCmdSave is not for saving your record. It is for saving design
changes to the current form or report and this is not allowed in an MDE.
To save the current record use...

If Me.Dirty = True Then Me.Dirty = False
 
S

Sylvain Lafontaine

You can also try « DoCmd.RunCommand acCmdSaveRecord »; however, I don't know
if this will be allowed under MDE.

S. L.

Rick Brandt said:
Dave Elliott said:
This code runs on the main forms drop down list for a customer, after
update.
After choosing a customer, then the list of clients for that customer would
be available.
It is necessary for it to run or else the client list will not be seen
correctly for the customer chosen.
Alternativley, I would have to save the record manually, then requery the
client list!
Here is my code, but after creating a mde, it errors out.
It says the command or action save isnt available now.
Is there anything else I can do?

DoCmd.RunCommand acCmdSave
Me.[Client ID].Requery
If err <> 2501 Then
MsgBox "Contact Tech Support"
End If

The acCmdSave is not for saving your record. It is for saving design
changes to the current form or report and this is not allowed in an MDE.
To save the current record use...

If Me.Dirty = True Then Me.Dirty = False
 
D

Dave Elliott

Would I put this code on the after update like it was originally or the On
Dirty Event?

Rick Brandt said:
Dave Elliott said:
This code runs on the main forms drop down list for a customer, after
update.
After choosing a customer, then the list of clients for that customer would
be available.
It is necessary for it to run or else the client list will not be seen
correctly for the customer chosen.
Alternativley, I would have to save the record manually, then requery the
client list!
Here is my code, but after creating a mde, it errors out.
It says the command or action save isnt available now.
Is there anything else I can do?

DoCmd.RunCommand acCmdSave
Me.[Client ID].Requery
If err <> 2501 Then
MsgBox "Contact Tech Support"
End If

The acCmdSave is not for saving your record. It is for saving design
changes to the current form or report and this is not allowed in an MDE.
To save the current record use...

If Me.Dirty = True Then Me.Dirty = False
 
R

Rick Brandt

Dave Elliott said:
Would I put this code on the after update like it was originally or the On
Dirty Event?

Well if you are using AfterUpdate then you don't need to issue a save of
any kind. By definition the record is already saved in the AfterUpdate
event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top