Record Count...Almost!

C

channell

Hello,

I posted a question, and got an answer that helped me for the most part.
Now, with better jargon and a better understanding of what I am looking to
do, I will pose this updated question:

I have a subform with a TextBox (txtMR) and a Botton next to it. When I
press this Button, a different Form pops up and and allows entries. On this
Pop-Up Form, in the Footer, I have a working record counter
(txtRecordCounter). Now, when I close this form, I want what is displayed in
the record counter TextBox (txtRecordCounter) to be displayed in the TextBox
(txtMR) on the first form I was talking about. Thank you so much for your
help! My code is as follows, but does not work. An error display "Object
Required".

Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

fENTRY!txtMR.Text = fMRDETAILS!txtRecordCount.Text

DoCmd.Close

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click
End Sub

-Scott Channell
 
D

Dirk Goldgar

channell said:
Hello,

I posted a question, and got an answer that helped me for the most part.
Now, with better jargon and a better understanding of what I am looking to
do, I will pose this updated question:

I have a subform with a TextBox (txtMR) and a Botton next to it. When I
press this Button, a different Form pops up and and allows entries. On
this
Pop-Up Form, in the Footer, I have a working record counter
(txtRecordCounter). Now, when I close this form, I want what is displayed
in
the record counter TextBox (txtRecordCounter) to be displayed in the
TextBox
(txtMR) on the first form I was talking about. Thank you so much for your
help! My code is as follows, but does not work. An error display "Object
Required".

Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

fENTRY!txtMR.Text = fMRDETAILS!txtRecordCount.Text

DoCmd.Close

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click
End Sub

-Scott Channell


Scott, if this code is on the form that contains txtRecordCount, then try
this version of your procedure:

'----- start of revised code -----
Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Forms!fENTRY!txtMR = Me!txtRecordCount

DoCmd.Close acForm, Me.Name, acSaveNo

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click
End Sub
'----- end of revised code -----

Note that I've made a few other modifications to the code besides just
fixing the object reference. You shouldn't have been using the .Text
property of the text boxes -- that would have failed, if the code had gotten
past the first error.
 
C

channell

Dirk,

I gave that a try, but an error message came up and stated that my database
could not find the form 'fENTRY' that was being referred to in Visual Basic.

Any other suggestions? Thank you!

-Scott Channell
 
D

Dirk Goldgar

channell said:
Dirk,

I gave that a try, but an error message came up and stated that my
database
could not find the form 'fENTRY' that was being referred to in Visual
Basic.

Any other suggestions? Thank you!

I assumed that your forms were named "fENTRY" and "fMRDETAILS" -- fENTRY the
original form, and fMRDETAILS the popup -- because these were the names you
seemed to be trying to use in your original code. That error message is
telling you that either "fENTRY" is not the name of the form, or else the
form is closed. Please verify the name of the form, and correct it in the
code if need be.

Did you close the form when you opened your popup form? If so, you didn't
mention that in your original post, and you'd have to reopen it (at the very
least) before assigning a value to a text box on it.
 
C

channell

Dirk,

The form names are correct; however, fENTRY is a subform in fMAINENTRY. I
hope that helps. But as far as the form names, these are the actual ones.
Thanks!

-Scott Channell
 
H

hans.updyke

The form names are correct; however, fENTRY is a subform in fMAINENTRY.  I
hope that helps.  But as far as the form names, these are the actual ones.  

So, if fENTRY is a subform, it won't be found in the Forms
collection. Instead, you must reference it as a control in it's
parent form (fMAINENTRY). It may be clearer if you type this in the
immediate window:

? Forms!fMAINENTRY!fENTRY.Name

Hans
 
D

Dirk Goldgar

channell said:
Dirk,

The form names are correct; however, fENTRY is a subform in fMAINENTRY. I
hope that helps.

Ah. The try this version:

'----- start of code -----
Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Forms!fMAINENTRY!fENTRY!txtMR = Me!txtRecordCount

DoCmd.Close acForm, Me.Name, acSaveNo

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click
End Sub
'----- end of code -----

Note, though, that in the above code, "fENTRY" must be the name of the
subform *control* (on fMAINENTRY) that displays the subform. That may or
may not be the same as the name of the form being displayed by the subform
control.
 
C

channell

Genius! I tried all sorts of different probabilities, but not that one.
Works perfectly! Thank you so much Dirk!

-Scott Channell
 

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

Similar Threads

Data Type in Textbox 1
multiple link criteria in form 6
2003 - 2007 VBA issue 6
Sorting records in a sub-form 5
Open a form for specific record. 3
Close command 1
Pass data to website 7
open excel spreadsheet 2

Top