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 2007

Tip: Looking for answers? Try searching our database.

Identify a subform in Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Zoltar54 - 05 Jul 2007 14:40 GMT
Can someone tell me how to identify a field on a subform using code?  I am
trying to create a routine that, when a customer is entered into the main
form and they are not in the list, the subform will accept a new entry.  

Currently I know that when specifying field names on a main form I can
simply type the field name or use Me.[fieldname].  To refer to a subform can
I use subfrmName.[fieldname]?

Z
Bob Quintal - 05 Jul 2007 14:15 GMT
> Can someone tell me how to identify a field on a subform using
> code?  I am trying to create a routine that, when a customer
[quoted text clipped - 6 lines]
>
> Z

to refer to a control on the subform you have to reference the
subform control's name property which may not be the same as the
sub's form name. You will find the subform control's name
property  
in the properties, under the other tab as name, the name of the
sub's form is in the properties Data tab as Control source.

That said,

me!child1.form![fieldname]

Signature

Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Zoltar54 - 05 Jul 2007 15:26 GMT
Just for clarification, would I then type:

me!subfrmCustomer.form![customerid] = newdata

so as to allow me to enter a new customer name and have that added to the
underlying tblCustomer table? (I have a number of other fileds such as Name,
Address etc.. for which, I assume the same process would apply).

> > Can someone tell me how to identify a field on a subform using
> > code?  I am trying to create a routine that, when a customer
[quoted text clipped - 17 lines]
>
> me!child1.form![fieldname]
Bob Quintal - 05 Jul 2007 15:37 GMT
> Just for clarification, would I then type:
>
[quoted text clipped - 4 lines]
> other fileds such as Name, Address etc.. for which, I assume
> the same process would apply).

if subfrmCustomer is both the name of the subform control and
the name of the form in the control, yes. If the two are
different, use the name of the control, not the form  

>> > Can someone tell me how to identify a field on a subform
>> > using code?  I am trying to create a routine that, when a
[quoted text clipped - 19 lines]
>>
>> me!child1.form![fieldname]

Signature

Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Zoltar54 - 05 Jul 2007 18:14 GMT
It seems to be working however when I try to enter a new customer name into
the subform I am having to problems.  

1) I reveive a warning stating that states:
You can't assign a value to this object because
The Object may be a control on a read-only form
The object may be on a form that is open in design view
The value may be too large for this field

None of these are true as far as I can tell.

2) Once I have entered a new customer (despite the error above I am able to)
I cannot get the mainform to requery the Customer list and use the newly
added customer to the current file.

Below is the code I have tried to use:

Private Sub CustomerID_NotInList(NewData As String, Response As Integer)
Response = acDataErrContinue
If MsgBox("The party you have entered is not in the list. Would you like to
add it?", vbOKCancel) = vbOK Then
Me.customerID.Undo
Me.customerID.Value = Null
Me.subfrmcustomer.SetFocus
Me.subfrmcustomer.Form.DataEntry = True

End If
End Sub

Any suggestions?

> > Just for clarification, would I then type:
> >
[quoted text clipped - 32 lines]
> >>
> >> me!child1.form![fieldname]
Bob Quintal - 05 Jul 2007 21:45 GMT
> It seems to be working however when I try to enter a new
> customer name into the subform I am having to problems.  
[quoted text clipped - 28 lines]
>
> Any suggestions?

I'm not sure about your error message.

If you pick an existing customer from the list do you get any
error message?

me.customer.undo and me.customerid,value = null seem to be
redundant. the Response = acDataErrContinue should take care of
that automatically.

I usually popup a small independent form to capture the data if
there are multiple fields to input, followed by setting the
Response to AcErrDataAdded which automatically requeries the
combobox.

see http://msdn2.microsoft.com/en-us/library/aa211431
(office.11).aspx



>> > Just for clarification, would I then type:
>> >
[quoted text clipped - 34 lines]
>> >>
>> >> me!child1.form![fieldname]

Signature

Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

kingston - 05 Jul 2007 14:55 GMT
This might help:

http://www.mvps.org/access/forms/frm0031.htm

>Can someone tell me how to identify a field on a subform using code?  I am
>trying to create a routine that, when a customer is entered into the main
[quoted text clipped - 5 lines]
>
>Z
Keith Wilby - 05 Jul 2007 15:13 GMT
> Can someone tell me how to identify a field on a subform using code?  I am
> trying to create a routine that, when a customer is entered into the main
[quoted text clipped - 6 lines]
>
> Z

IIRC:

[Forms]![frmMain]![sfrmSub].ctlControl

Keith.
www.keithwilby.com
 
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.