?
Solved

Access - New Record on Subform (Docmd or RunCommand) from that form's Tabbed Form

Posted on 2012-12-20
9
Medium Priority
?
547 Views
Last Modified: 2012-12-21
Hello all!

I have a Main form on that main form I have

1 subform (with it's own subform) AND also
1 Tabbed Form with the tabs of the Tabbed Form having Subform's on them.

I am attempting to transfer info
FROM:
One of the Tabbed Form's Subform
TO
The other Subform of the Main Form

When I click a command button on one of the Tabbed Forms Sub it is transferring the data to the other MainForm's Sub but I can not get it to go to a new record on that form.  

When i use Docmd
I get an error
Run-Time error 2498
An Expression you entered is the wrong data type for one of the arguments.

        DoCmd.GoToRecord , Forms![frm_Inv]![frm_ctl_MiscInv].Form![sfrm_dta_MiscInvDetails], acNewRec

If I put quotations around the Form name I get the object. xxxxxxxx isn't open.

If I put Open/Close parenthesis around it (no quotations) I get the same "wrong argument" error.

How can I correct it?
0
Comment
Question by:wlwebb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 40

Expert Comment

by:als315
ID: 38710403
Records should be added to tables, so you can create append query and run it.
Try this syntax if you like follow your idea:
docmd.GoToRecord  acDataForm, Forms![frm_Inv]![frm_ctl_MiscInv].Form![sfrm_dta_MiscInvDetails], acNewRec
I hope form [frm_Inv] is opened
0
 

Author Comment

by:wlwebb
ID: 38710444
Thanks for replying Als315

Made that fix.  Still get "Run-Time error 2498
An expression you entered is the wrong data type for one of the arguments."

Just to Reiterate, this Main form has 1 subform Plus 1 Tabbed form with Subforms.  I'm trying to get it to move data from the Tabbed Form's Sub to the Main Form's Other Subform.

When the Main form opens, the Subform (not the Tabbed form's sub) opens with "New" in the Record.  The command button on the Tabbed Form's Sub does work to transfer the first line of data into the Main Form's Subform but when it hits the dcmd....acnewRec is where it is erroring.


Since that SubForm is on the Main Form and both the Main form, the Tabbed Form and the SubForm are all open, isn't the SubForm therefore open?
0
 
LVL 40

Expert Comment

by:als315
ID: 38711966
Will be good if you upload sample DB with this form and related table.
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:wlwebb
ID: 38712048
Here you go....

when you open it the form is
frm_EstimWorkup

Click on a Process on the Main form which will eventually make the Tab Form Sub visible (left all visible for now) input whatever numbers in the textbox and click save.  Should transfer into over to the Mainform's Sub (the right side of the form with blue heading)
TestForm-MainTabSub-MainFormSub.accdb
0
 
LVL 40

Accepted Solution

by:
als315 earned 2000 total points
ID: 38712185
Try this (without newrecord). Only Process01 (Page2)
TestForm-MainTabSub-MainFormSub.accdb
0
 

Author Comment

by:wlwebb
ID: 38712898
Als315
I get a Run-Time Error '2455'
You entered an expression that has an invalid reference to the property Dirty.

Happens when I input numbers on the Page2 Tabbed form Subform sfrm_WkSh01

Stops on If Me.Dirty Then Me.Dirty=False

Private Sub cmdSave_Click()
Dim i As Integer, J As Integer
Dim rs As DAO.Recordset
J = Me.cboInv.ListCount
Set rs = CurrentDb.OpenRecordset("dta_EstimDtail")
        Forms![frm_EstimWorkup]![frm_ctl_Inv].Form![WkShiftID].SetFocus
        If Me.Dirty Then Me.Dirty = False
    For i = 1 To J
        rs.AddNew
0
 
LVL 40

Expert Comment

by:als315
ID: 38713229
Problem is new record on from frm_ctl_Inv. You should save new InvCtlID to table Ctl_Inv before you start add records to table dta_EstimDtail. This new record is added when you press Process01 button on Page1.
When you got an error do you have value in InvCtlID field?
But I have no this error. Check for InvCtlID was added
TestForm-MainTabSub-MainFormSub.accdb
0
 

Author Comment

by:wlwebb
ID: 38713272
Just fixed it.......

There was a Value in the field InvCtlID....

Problem was I had to use the Whole name instead of Me.

Once I changed that it worked......

I googled the error and MSDN came up with an Unbound Form error Knowledgebase Article...  discussed about Setting Focus etc.... that lead me to the answer....

Thanks Als.....
0
 

Author Closing Comment

by:wlwebb
ID: 38713275
Thanks you for your help Als!!!!
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 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