Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2005

Tip: Looking for answers? Try searching our database.

accessing a subform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Donna - 23 Jul 2005 19:53 GMT
I have a form A where I have a command button that needs to open Form B.  
Form B has a subform C on it in datasheet view.  I need the command button to
also add a new record into subform c.  I keep trying to get it to do that but
is says it can't find my subform.  Form B opens just fine, but anytime I try
to go any further with writing code to add a new record, it keeps adding the
new record to form B instead of form C.  How do I correctly call subform C?
Thanks!
Arvin Meyer [MVP] - 23 Jul 2005 20:37 GMT
The proper syntax for addressing a subform is:

Forms!FormName!SubformControlName.Form!ControlName

On your form that would be:

Forms!FormB!SubformC.Form!txtIDField

The SubformControlName is not necessarily the same as the name of the
subform. Look at the Name property in your form's property sheet for the
correct one.
Signature

Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

> I have a form A where I have a command button that needs to open Form B.
> Form B has a subform C on it in datasheet view.  I need the command button to
[quoted text clipped - 3 lines]
> new record to form B instead of form C.  How do I correctly call subform C?
> Thanks!
Donna - 24 Jul 2005 22:49 GMT
Okay, what it's doing is writing over existing records rather than adding it
as a new record.  The subform is in dataSHEET view & I need all the records
for that account to show up so the user will know whether or not they really
want to "commit" this record as it stands. They may need to "tweak" it, if
the customer has a credit balance or whatever.  Somehow I have to get it to
go to a new record without it going into DataENTRY view.

Here's the code I have so far:
Dim stLinkCriteria As String, form1 As String, form2 As String
   Dim form3 As String, form4 As String, qry As String

   form1 = "frmAccount"
   form2 = "frmTransaction"
   form3 = "frmCustomer"
   form4 = "frmCustomerTourDataEntry"
   stLinkCriteria = "[CID]=" & Me![CID]

   'Saves current record in tblCustomerTour
   DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
   
   'Opens account form to current customer
   DoCmd.OpenForm form1, , , stLinkCriteria
   'DoCmd.GoToRecord , , acNewRec
   Forms!frmAccount!frmTransaction.Form![TID] =
Form_frmCustomerTourDataEntry.TID
   Forms!frmAccount!frmTransaction.Form![Type] = "Charge"
   Forms!frmAccount!frmTransaction.Form![Charge-DR] =
Form_frmCustomerTourDataEntry.CustomerPrice

Right now the line that adds a new record is commented out because it's
opening in DATAENTRY mode, not showing all the other records that need to be
shown so that the Account BALANCE text box on the parent form contains the
correct amount (it's a calculated figure based on the entries in the
transaction subform)
Thanks in advance for your help!

> The proper syntax for addressing a subform is:
>
[quoted text clipped - 19 lines]
> C?
> > Thanks!
Ofer - 23 Jul 2005 20:39 GMT
From FormA on the open form command line pass an openargs
DoCmd.OpenForm "FormB", , , , , , "AddNewRecord"

On the on load event of FormB Write the code
If Me.OpenArgs = "AddNewRecord" Then
   Me.SubFormC.SetFocus
   DoCmd.GoToRecord , , acNewRec
End If

> I have a form A where I have a command button that needs to open Form B.  
> Form B has a subform C on it in datasheet view.  I need the command button to
[quoted text clipped - 3 lines]
> new record to form B instead of form C.  How do I correctly call subform C?
> Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.