By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,959 Members | 1,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,959 IT Pros & Developers. It's quick & easy.

Creating continuous forms

P: 18
I have a main form which has a Comment Area Section whose source object is a form fsubCaseDetails.
fsubCaseDetails has a textbox.The main form which when viewed in form view displays the fsubcaseDetails form in the Comments Area section.
I need to enter comments into the form fsubCaseDetails by clicking on the AddComments button which opens a form frmZoom.When a user clicks on AddComments button frmZoom is opened and he/she enters the comments into the textbox of frmZoom and finally the comments entered in the frmZoon will get transfered to form fsubcasedetails on clicking save button of frmZoom.
When the text get transferred into fsubcasedetails form,it will get locked and wiil not allow any further comments to be entered.
When some text get transferred to fsubcasedetails form,another fsubcasedetails will get opened in the Comment Area section below the first form.
If now a user wants to add some comments by opening the frmZoom,the text comments should get transferred to the 2nd fsubcasedetails form which got created.Similarly the process wll go on.

Could anyone please help me in the above problem.
Specifically how continious forms will be created and the text will get transfered to the next next forms.
This is very urgent.

Thanks.
Sep 22 '08 #1
Share this Question
Share on Google+
30 Replies


NeoPa
Expert Mod 15k+
P: 31,343
This is really quite unclear. Items are not introduced in any understandable order.

The best I can do with this is to provide a possibly helpful link on Referring to Items on a Sub-Form.
Sep 23 '08 #2

P: 18
This was not really helpful.Let me explain the scenario more clearly.

Logging into my application brings me into frmMain where it displays certain cases.
Clicking on any particular case,"frmCase" is opened.
This form frmCase has many tabs among which "File Details" is one.
Clicking on "File Details" tab, a screen appears which has a "Comment Area" section inside which there is continuous form "fsubCaseDetails".

I need to enter comments to the form "fsubCaseDetails" through a form frmZoom.frmZoom will get open on clicking a button "Add Comments" which is present in frmCase.

What I need to do so that the comments entered in the frmZoom will get transferred to fsubcasedetails on clicking "save" button of frmZoom.
Sep 25 '08 #3

FishVal
Expert 2.5K+
P: 2,653

NeoPa
Expert Mod 15k+
P: 31,343
This was not really helpful.Let me explain the scenario more clearly.
That would be a good starting point yes.

Now, I get that when you say tab you're referring to a Page control, but would I be right in guessing that your "Comment Area" section refers to a SubForm control (as opposed to the form contained within it - see earlier link for details)?

fsubCaseDetails must be the name of a form which is displayed within the SubForm control in continuous mode. frmZoom is an independent form which is merely linked logically by code.

Can you please confirm this understanding, and possibly post the code you use ( The full procedure please) to open frmZoom.
Sep 25 '08 #5

P: 18
What you have understood is perfectly correct.
Let me give you more inputs as well.

Here fsubCaseDetails(Row Source is a query) is a subform in frmCase.
The textbox in fsubCaseDetails is locked that means user doesn't have the ability to directly enter into it.

A user can only enter text to it if he/she clicks on "Add Comments" button (present in frmCase) which opens frmZoom(a zoom view to fsubCaseDetails).
Anything entered in the frmZoom shoud get transfer and saved in fsubCaseDetails when the "Save" button of frmZoom is clicked.

After clicking Save, if the user wants to add some more comments then he/she has to click again the "Add Comments" button which would pop up the frmZoom and the text entered should get transfer to the 2nd row of fsubCaseDetails.
The problem is that after writing some text to frmZoom and clicking Save button,its not getting transfer to fsubCaseDetails.I might be missing some code in events of both of the forms such as open event,Activate event,Load event etc.

I need to know what code would solve my requirement.
Oct 1 '08 #6

NeoPa
Expert Mod 15k+
P: 31,343
That is a lot clearer, but I would still like to see your code for this.

This means that I can see better what you already understand, and concentrate on the gaps.
Oct 1 '08 #7

P: 18
Code for Save button in frmZoom:
========================
Expand|Select|Wrap|Line Numbers
  1. txtEntered = Me.txtZoom.Value
  2. Forms![frmCase]![fsubCaseDetail].Form![txtDetails] = txtEntered
  3. DoCmd.Close acForm, Me.Name
where txtEntered is a global variable.

I am new to VB Access and need to know on a high level what all codes are required for my requirement.
Oct 1 '08 #8

NeoPa
Expert Mod 15k+
P: 31,343
This code isn't perfect, but it's pretty adequate. If it's executed it should at least update your calling form with the latest data from frmZoom.

Is this not happening at all?
Oct 2 '08 #9

NeoPa
Expert Mod 15k+
P: 31,343
Some better code, if you want to add data in to subsequent lines if frmZoom is repeated :
Expand|Select|Wrap|Line Numbers
  1. With Forms![frmCase].[fsubCaseDetail].Form
  2.   .[txtDetails] = .[txtDetails] & vbCrLf & Me.txtZoom
  3. End With
  4. DoCmd.Close
This assumes txtDetails can expand to show multiple lines. I hope at this stage you're not referring to multiple records on your main form ([frmCase]), that would change the question entirely and to have left out explaining that would be, well, certainly not clever.
Oct 2 '08 #10

P: 18
Hey I would just like to know what code would pass the text from frmZoom to fsubCaseDetails on clicking the "Save" button of frmZoom and after doing it ,the form should exit.

My code is not passing the value and not closing the form as well.
Oct 3 '08 #11

FishVal
Expert 2.5K+
P: 2,653
Hey I would just like to know what code would pass the text from frmZoom to fsubCaseDetails on clicking the "Save" button of frmZoom and after doing it ,the form should exit.

My code is not passing the value and not closing the form as well.
Hi.

The code you've posted in msg #8 is expected to do something or at least fail with error message. If nothing happens, then I would like to ask:
- Do you have any error handling code?
- Are you sure the code runs?

Regards,
Fish.
Oct 3 '08 #12

P: 18
Ya the code is showing the following error:
Access cann't find the field fsubCaseDetails reffered to in your expression.

Let me tell the you the existing scenario as well.
In the existing scenario the frmZoom is opened by double clicking the text box of fsubCaseDetails.
But in the TO-BE scenario the text box in the form fsubCaseDetails should be locked and the user should only add comments to it by clicking on "Add Comments" button which would open frmZoom.

Can we modify the following existing code and meet our requirement?
One more thing there is no code associated with the "Save" button of frmZoom which could ensure the value passing from it to fsubCaseDetails.
I think the data is also passed through the following code.I am not getting the code clearly.If you can explain it and find out a way, then it would be great.

Opening of frmZoom on double clicking the text box of fsubCaseDetails:
================================================== =
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtCaseDetails_DblClick(Cancel As Integer)
  2.    On Error Resume Next
  3.    gfncZoomWindow (Me.NewRecord = False)
  4. End Sub
Function to open Zoom window:
=======================
Expand|Select|Wrap|Line Numbers
  1. Function gfncZoomWindow(Optional blnLock As Boolean)
  2.    'Open Zoom Window With Contents Of Active Text Box Control
  3.    On Error Resume Next
  4.    Dim frm As Form      'Active Form
  5.    Dim strFormName As String
  6.    Dim blnLockEdit As Boolean
  7.  
  8.    If Not IsMissing(blnLock) Then blnLockEdit = blnLock
  9.  
  10.    If IsError(Screen.ActiveForm) = False Then
  11.       Set frm = Screen.ActiveForm
  12.  
  13.       If frm.ActiveControl.ControlType = acSubform Then
  14.          If frm.ActiveControl.Form.ActiveControl.ControlType = acTextBox Then
  15.             'Tack . At End To Denote Subform
  16.             DoCmd.OpenForm "frmZoom", , , , IIf(blnLock = True, acFormReadOnly, acFormPropertySettings), acDialog, frm.Name & "."
  17.          End If
  18.       ElseIf frm.ActiveControl.ControlType = acTextBox Then
  19.          DoCmd.OpenForm "frmZoom", , , , IIf(blnLock = True, acFormReadOnly, acFormPropertySettings), acDialog, frm.Name & "."
  20.       End If
  21.    End If
  22. End Function
Oct 3 '08 #13

FishVal
Expert 2.5K+
P: 2,653
Ok.

That is half of the puzzle. Could you post all the code in [frmZoom] module?
Oct 3 '08 #14

P: 18
Here it is:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Dim mfrm As Form              'Active Form
  5. Dim mblnCancel As Boolean     'Indicates Cancel Pressed
  6.  
  7. Private Sub cmdCancel_Click()
  8.    On Error Resume Next
  9.    DoCmd.SetWarnings False
  10.    DoCmd.RunCommand acCmdUndo
  11.    DoCmd.SetWarnings True
  12.    mblnCancel = True
  13.    DoCmd.Close acForm, Me.Name
  14. End Sub
  15.  
  16. Private Sub cmdSave_Click()
  17.    On Error GoTo Err_cmdSave_Click
  18.  
  19.    txtEntered = Me.txtZoom
  20.    Forms.fsubCaseDetails.txtDetails = txtEntered
  21.    DoCmd.Close acForm, Me.Name
  22.  
  23. Exit_cmdSave_Click:
  24.    Exit Sub
  25. Err_cmdSave_Click:
  26.    MsgBox Error$, vbCritical, "Error: cmdSave_Click"
  27.    Resume Exit_cmdSave_Click
  28. End Sub
  29.  
  30.  
  31. Private Sub Form_Open(Cancel As Integer)
  32.    On Error GoTo Err_Form_Open
  33.    Dim varOpenArg As Variant        'Value Of Open Argument
  34.    Dim ctl As Control
  35.    Dim lngAddHeight As Long         'Add Height Of Detail Section
  36.    Dim lngPos As Long
  37.  
  38.    'Set Initial Height
  39.    DoCmd.Restore
  40.    DoCmd.RunCommand acCmdSizeToFitForm
  41.  
  42.    'Set Module Form Variable
  43.    varOpenArg = Me.OpenArgs
  44.    If Not IsNull(varOpenArg) Then
  45.       If InStr(1, varOpenArg, ".") Then
  46.          lngPos = InStr(1, varOpenArg, ".")
  47.          If lngPos > 0 Then
  48.             Set mfrm = Forms(Left(varOpenArg, lngPos - 1))
  49.             Set mfrm = mfrm.ActiveControl.Form
  50.          Else
  51.             Set mfrm = Forms(varOpenArg)
  52.          End If
  53.       Else
  54.          Set mfrm = Forms(varOpenArg)
  55.       End If
  56.  
  57.       Me.txtZoom = mfrm.ActiveControl.Value
  58.  
  59.       'Set The Locked Property To Match The ActiveControl Locked Property
  60.       If mfrm.ActiveControl.ControlType = acTextBox Then
  61.          Me.txtZoom.Locked = mfrm.ActiveControl.Locked
  62.       End If
  63.       SendKeys "{F2}"
  64.    End If
  65.  
  66. Exit_Form_Open:
  67.    Exit Sub
  68. Err_Form_Open:
  69.    MsgBox Error$, vbCritical, "Error: Form_Open"
  70.    Resume Exit_Form_Open
  71. End Sub
  72.  
  73. Private Sub Form_Unload(Cancel As Integer)
  74.    On Error Resume Next
  75.    If mblnCancel = False Then mfrm.ActiveControl.Value = Me.txtZoom
  76. End Sub
Oct 3 '08 #15

NeoPa
Expert Mod 15k+
P: 31,343
Hey I would just like to know what code would pass the text from frmZoom to fsubCaseDetails on clicking the "Save" button of frmZoom and after doing it ,the form should exit.

My code is not passing the value and not closing the form as well.
Hey, if you'd responded to post #9 then I'd have known the exact situation we're dealing with. If you leave me guessing instead of responding clearly, you can expect me to be unclear as to exactly what IS going on.

Even after your less than polite reply, you STILL haven't answered half the questions posed of you and your situation is STILL unclear.
Oct 3 '08 #16

NeoPa
Expert Mod 15k+
P: 31,343
Ya the code is showing the following error:
Access cann't find the field fsubCaseDetails reffered to in your expression.
You're telling us this in post #13!! Have you given ANY consideration to this question? I suggest if you want some help, you pay more attention to those trying to help you, rather than showing attitude when they can't read your mind.
Oct 3 '08 #17

NeoPa
Expert Mod 15k+
P: 31,343
Ya the code is showing the following error:
Access cann't find the field fsubCaseDetails reffered to in your expression.
This is very confusing as the code you posted earlier (post #8) is quite different from the code you subsequently posted (post #15 - lines #19 to #21). There is also no indication as to which line triggers the error message shown.

I shall will await your response.
Oct 3 '08 #18

FishVal
Expert 2.5K+
P: 2,653
@bibek24

The code you have is kludgy and unreasonably complicated.
Since the question was several times asked on the forum I've written a simple howto concerning different approaches to the problem.

Regards,
Fish
Oct 3 '08 #19

P: 18
The code in #8 is showing the error which is my TO BE code as per my requirement.
All other subsequent codes are for the existing scenario.
My requirement is to enhance the existing scenario and what I have explained in #13 is the existing scenario.
Oct 3 '08 #20

NeoPa
Expert Mod 15k+
P: 31,343
@Fish, Did you mean to post that in VB / VBA HowTo section? I would have thought this was Access specific.

PS. Nice article :)
Oct 3 '08 #21

FishVal
Expert 2.5K+
P: 2,653
@Fish, Did you mean to post that in VB / VBA HowTo section? I would have thought this was Access specific.

PS. Nice article :)
:)

I intended to post it in Access howtos section but accidentally posted it in VB/VBA one. Please, move it appropriately.
Oct 3 '08 #22

NeoPa
Expert Mod 15k+
P: 31,343
The code in #8 is showing the error which is my TO BE code as per my requirement.
All other subsequent codes are for the existing scenario.
My requirement is to enhance the existing scenario and what I have explained in #13 is the existing scenario.
Bibek,

As Fish has already posted a fairly comprehensive article on the subject I will assume all your questions are resolved for now. I will content myself with a comment I was leading up to before, depending on one of the answers I was anticipating :
Sometimes, code can be inactive (remain untriggered) even if the code is perfectly correctly done, simply because the property of the object (I'm referring to the On Click of a Command Button for example or the On Open of the form itself even) is not set to the value "[Event Procedure]". This is found when looking at the object in Design View and showing the Properties (Alt-Enter).

If you find, after going through Fish's article that you still have questions then please come back and post them.
Oct 3 '08 #23

NeoPa
Expert Mod 15k+
P: 31,343
:)

I intended to post it in Access howtos section but accidentally posted it in VB/VBA one. Please, move it appropriately.
Moved :)
Oct 3 '08 #24

P: 18
The approach looks good.Thanks for this.
But I have the following questions:

1) I am always getting a debugging error when am trying to refer a subform in the main form.

for exp
With Forms!frmChild1
.txb.ControlSource = Me!fsubCaseDetails.Form!txb.ControlSource

2) To overcome this I kept the "Add Comments" button in the subform itself and tried with the same code as posted

With Forms!frmChild1
.txb.ControlSource = Me.txb.ControlSource

It was working fine but this always update the first record in the form,the control is not moving to the 2nd record.
So how to move the control to 2nd record once the 1st record has been saved?
Oct 6 '08 #25

FishVal
Expert 2.5K+
P: 2,653
....
It was working fine but this always update the first record in the form,the control is not moving to the 2nd record.
So how to move the control to 2nd record once the 1st record has been saved?
As soon as both forms are bound to the same Recordset object, they will be always pointed to the same record.

Regards,
Fish.

P.S. I didn't really understand your question.
Oct 6 '08 #26

NeoPa
Expert Mod 15k+
P: 31,343
As this refers directly to Fish's code (in the article) I will allow Fish to respond.

If you hear nothing after a couple of days then bump the thread and I will have a look into it myself.

PS. How did he do that :S
Oct 6 '08 #27

P: 18
I mean to sat how to point to the 2nd record of the form once the 1st record is saved.Suppose I want to enter something to the 2nd record then how to do that?
Oct 6 '08 #28

FishVal
Expert 2.5K+
P: 2,653
As I've already said both main and child form being bound to the same Recordset object are pointed to the same record, no matter where do you click navigation buttons.

Option 1. (as in the example)
Select appropriate record on main form, open child form, alter data and either submit or cancel input.

Option 2.
Add navigation bar to the child form. When child form is opened you may use its navigation bar to walk through records.

Hope this helps.
Oct 6 '08 #29

P: 18
I am sorry but I am really not getting help for my requirement which is as follows:

As many number of times the child form will be populated with some text and clicked on "Submit" button that many number number of records would be created in the parent form.

i.e First text entered to the child form would make up the first record in the parent form,second would make up the 2nd record and so on.
Oct 7 '08 #30

FishVal
Expert 2.5K+
P: 2,653
I am sorry but I am really not getting help for my requirement which is as follows:

As many number of times the child form will be populated with some text and clicked on "Submit" button that many number number of records would be created in the parent form.

i.e First text entered to the child form would make up the first record in the parent form,second would make up the 2nd record and so on.
Hello, bibek.

I thought it is quite straightforward - when you need to do the same on usual form, you simply go to new record, enter data, go to new record and so on.

That means, the only thing [Submit] button has to do is to point child form to new record. For example using DoCmd.GoToRecord method.

Kind regards,
Fish.
Oct 7 '08 #31

Post your reply

Sign in to post your reply or Sign up for a free account.