Solved

MSAccess Forms

Posted on 2011-09-09
14
188 Views
Last Modified: 2012-05-12
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!txtTermMsg
frmSubViewEmailMsg!txtExcpMsg
frmSubViewEmailMsg!txtBothMsg

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
0
Comment
Question by:Lambel
  • 6
  • 5
  • 3
14 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36511967
there are a lot more things to do to accomplish this..
better if you can upload a copy of the db..
0
 
LVL 26

Expert Comment

by:Nick67
ID: 36512227
<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;SomeControlName" 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!SomeControlName.Value = me.theEditedControl.value
0
 

Author Comment

by:Lambel
ID: 36512838
I've attached a database file with the forms and code for the issue I described above.
 Email-Forms-201100909-9121.zip
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36512907
you should have included the form "frmReportGenerator"
0
 
LVL 26

Expert Comment

by:Nick67
ID: 36513028
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,
0
 

Author Comment

by:Lambel
ID: 36513082
0
 

Author Comment

by:Lambel
ID: 36513306
@Nick67:  The code never gets that far.

Private Sub cmdEditTerMsg_Click()
    DoCmd.OpenForm "frmSubEmailMsgEdit", acNormal, , , , , _    '<------ Bombs Here
    Forms!frmReportGenerator!frmSubViewEmailMsg.TerminatingMsg.value
    Forms!frmReportGenerator!frmSubEmailMsgEdit.txtWhatMsg = "TerminatingMsg"
End Sub

I get error message: "run time error '438'.  Object doesn't support this property or method".
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36513330


use this code

Private Sub cmdEditTerMsg_Click()

'    DoCmd.OpenForm "frmSubEmailMsgEdit", acNormal, , , , , _    '<------ Bombs Here
'    Forms!frmReportGenerator!frmSubViewEmailMsg.TerminatingMsg.value
'    Forms!frmReportGenerator!frmSubEmailMsgEdit.txtWhatMsg = "TerminatingMsg"

    DoCmd.OpenForm "frmSubEmailMsgEdit", acNormal, , , , , _    
    Forms!frmReportGenerator!frmSubViewEmailMsg.Form!TerminatingMsg.value

'    Forms!frmReportGenerator!frmSubEmailMsgEdit.txtWhatMsg = "TerminatingMsg"

End Sub
0
 
LVL 26

Expert Comment

by:Nick67
ID: 36513394
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
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36513396
test this and posts what ever comments you have
Email-Forms-201100909-9121.mdb
0
 

Author Comment

by:Lambel
ID: 36513399
I'm still getting stuck in the same place ( run time error 2501) See attached printscreen file.
Error-Email-Forms.doc
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 36513406
Lambel,

check the uploaded db at http:#a36513396 


0
 

Author Closing Comment

by:Lambel
ID: 36513589
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
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36513633
I commented the erring codes and replace them with the correct codes. You can check them from the modules of the two forms
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question