Lambel
asked on
MSAccess Forms
I have a form frmReportGenerator with several pages (tabs). It contains functions to customize reports and email them out.
The pages have subforms, including frmSubViewEmailMsg for maintaining the email messages.
The recordSource for this form is table tblEmailMessage. This table has 3 memo fields: TerminatingMsg, ExceptionsMsg, BothMsg. The form displays these fields in 3 textboxes:
frmSubViewEmailMsg!txtTerm Msg
frmSubViewEmailMsg!txtExcp Msg
frmSubViewEmailMsg!txtBoth Msg
On this form, the textboxes are view only (locked). To allow the user to edit them, there is a command button (“EDIT”) next to each textbox. When the user clicks on the EDIT button, it opens up a popup form frmSubEmailMsgEdit that has a textbox containing the message text. On this form the textbox is unlocked to allow the user to edit, then save the changes to the message text.
I am having trouble figuring out how to pass the name of the message type so that the changes can be saved to the correct field in the table tblEmailMessage. I’m already passing the message text using the arguments of the DoCmd.OpenForm command. What am I overlooking here??
Thanks, Lynn
Email-Forms-Printscreen.doc
The pages have subforms, including frmSubViewEmailMsg for maintaining the email messages.
The recordSource for this form is table tblEmailMessage. This table has 3 memo fields: TerminatingMsg, ExceptionsMsg, BothMsg. The form displays these fields in 3 textboxes:
frmSubViewEmailMsg!txtTerm
frmSubViewEmailMsg!txtExcp
frmSubViewEmailMsg!txtBoth
On this form, the textboxes are view only (locked). To allow the user to edit them, there is a command button (“EDIT”) next to each textbox. When the user clicks on the EDIT button, it opens up a popup form frmSubEmailMsgEdit that has a textbox containing the message text. On this form the textbox is unlocked to allow the user to edit, then save the changes to the message text.
I am having trouble figuring out how to pass the name of the message type so that the changes can be saved to the correct field in the table tblEmailMessage. I’m already passing the message text using the arguments of the DoCmd.OpenForm command. What am I overlooking here??
Thanks, Lynn
Email-Forms-Printscreen.doc
<I’m already passing the message text using the arguments of the DoCmd.OpenForm command>
So, you are using OpenArgs?
Are you passing the text itself?
Or are you telling the new form to go get the text from Forms!SomeForm!SomeControl ?
Or are you telling it some SQL,i.e. "select somefield from sometable;" ?
If you are using OpenArgs, I like to pass in a semi-colon delimited list of arguments.
I then use SomeArray() = Split(Me.OpenArgs,";") to break them up.
You could pass in "SomeFormName;SomeControlN ame" and then based on that either write the edits to a table via recordset code and requery the original control or write the changes to the control directly via Forms!SomeFormName!SomeCon trolName.V alue = me.theEditedControl.value
So, you are using OpenArgs?
Are you passing the text itself?
Or are you telling the new form to go get the text from Forms!SomeForm!SomeControl
Or are you telling it some SQL,i.e. "select somefield from sometable;" ?
If you are using OpenArgs, I like to pass in a semi-colon delimited list of arguments.
I then use SomeArray() = Split(Me.OpenArgs,";") to break them up.
You could pass in "SomeFormName;SomeControlN
ASKER
I've attached a database file with the forms and code for the issue I described above.
Email-Forms-201100909-9121.zip
Email-Forms-201100909-9121.zip
you should have included the form "frmReportGenerator"
Ok,
You are using OpenArgs to pass in the text...
And then using code to set the value of that very small textbox
And you are setting it to the value of the ControlSource of the original textbox
So this is probable what you are asking about
'If we make it this far we can save the changes to the message records
rs.Edit
'rs.Fields(msgName) = Me.txtMsg '<--- this is bad
rs.Field(Me.txtWhatMsg) = Me.txtMsg '<---This is what you want
rs.Update
Now,
You are using OpenArgs to pass in the text...
And then using code to set the value of that very small textbox
And you are setting it to the value of the ControlSource of the original textbox
So this is probable what you are asking about
'If we make it this far we can save the changes to the message records
rs.Edit
'rs.Fields(msgName) = Me.txtMsg '<--- this is bad
rs.Field(Me.txtWhatMsg) = Me.txtMsg '<---This is what you want
rs.Update
Now,
ASKER
@Nick67: The code never gets that far.
Private Sub cmdEditTerMsg_Click()
DoCmd.OpenForm "frmSubEmailMsgEdit", acNormal, , , , , _ '<------ Bombs Here
Forms!frmReportGenerator!f rmSubViewE mailMsg.Te rminatingM sg.value
Forms!frmReportGenerator!f rmSubEmail MsgEdit.tx tWhatMsg = "TerminatingMsg"
End Sub
I get error message: "run time error '438'. Object doesn't support this property or method".
Private Sub cmdEditTerMsg_Click()
DoCmd.OpenForm "frmSubEmailMsgEdit", acNormal, , , , , _ '<------ Bombs Here
Forms!frmReportGenerator!f
Forms!frmReportGenerator!f
End Sub
I get error message: "run time error '438'. Object doesn't support this property or method".
use this code
Private Sub cmdEditTerMsg_Click()
' DoCmd.OpenForm "frmSubEmailMsgEdit", acNormal, , , , , _ '<------ Bombs Here
' Forms!frmReportGenerator!f
' Forms!frmReportGenerator!f
DoCmd.OpenForm "frmSubEmailMsgEdit", acNormal, , , , , _
Forms!frmReportGenerator!f
' Forms!frmReportGenerator!f
End Sub
Ok,
You second sample just bombs massively for me.
Here is your first sample
The FIRST edit message button is working.
Earlier in that code you were setting msgName
Had you done
msgName = me.txtWhatMsg.value, the code would have worked.
My change works too
Email-Forms-201100909-9121.mdb
You second sample just bombs massively for me.
Here is your first sample
The FIRST edit message button is working.
Earlier in that code you were setting msgName
Had you done
msgName = me.txtWhatMsg.value, the code would have worked.
My change works too
Email-Forms-201100909-9121.mdb
test this and posts what ever comments you have
Email-Forms-201100909-9121.mdb
Email-Forms-201100909-9121.mdb
ASKER
I'm still getting stuck in the same place ( run time error 2501) See attached printscreen file.
Error-Email-Forms.doc
Error-Email-Forms.doc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Capricorn and Nick67 - thanks for all your help and comments. Capricorn1: That last file you sent worked! I'm not sure what fixed it, but I'm glad to move on at this point!
Thanks again,
Lynn
Thanks again,
Lynn
I commented the erring codes and replace them with the correct codes. You can check them from the modules of the two forms
better if you can upload a copy of the db..