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 / May 2007

Tip: Looking for answers? Try searching our database.

Getting Data from Main Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ajay - 14 May 2007 06:53 GMT
Using Access 2000:
I need to add Client firms and their Salesmen to Clients and Staff tables.
I created form frmAddClient, where I add the information and two phone
numbers for the Client firm.
In the AddStaff subform, where I add the information for Sales staff, I
need the Client firm's phone numbers appear as default, so that I can
change them only where appropriate.

Can someone help this newbie with how the Control Source property should
be written?
Thanks a bunch.
Ajay.
Steve Schapel - 14 May 2007 09:48 GMT
Ajay,

I don't think the Control Source is applicable here.

There are a couple of approaches you could take here.

How I would probably do it, is to enter the Staff phone number *only if*
it is different from the Client phone number, otherwise leave it blank.

In this case, whenever you need a phone number for a staff member, for
example in your reports, you can use something like this in the query:
Nz([Staff].[Phone],[Clients].[Phone])

Alternatively, you can use code to assign the Client phone number to the
Staff phone number field.  This would be my second choice.  Even then, I
would not do it the way you suggested, where the Client number is
entered for the Staff, and then you have to edit it as required.  Once
again, leave the Staff phone number blank if it is the same as the
Client number, and then, on the Before Update event of the subform, code
something like this:
 If IsNull(Me.Phone) Then
    Me.Phone = Me.Parent.Phone
 End If

Signature

Steve Schapel, Microsoft Access MVP

> Using Access 2000:
> I need to add Client firms and their Salesmen to Clients and Staff tables.
[quoted text clipped - 8 lines]
> Thanks a bunch.
> Ajay.
Ajay - 14 May 2007 18:43 GMT
Many thanks for your prompt suggestion, Steve.
I would have preferred to have the phone numbers appear as I originally
stated, yet I would accept your suggestion.
I am afraid I may not be coding it the correct way and may be you can
spot my error/s.
I opened the AddStaff subform in design view. Right-clicked on the input
boxes to select Build event... and added the following VB code:

Private Sub Phone_BeforeUpdate(Cancel As Integer)
   If IsNull(Me.Phone) Then
       Me.Phone = Me.Parent.MainPhone
   End If
End Sub

Private Sub AltPhone_BeforeUpdate(Cancel As Integer)
   If IsNull(Me.AltPhone) Then
       Me.AltPhone = Me.Parent.WorkPhone
   End If
End Sub

The phone fields in Staff table remain blank before, during and after
entering the info into other Client table as well as other Staff table
fields.
Thanks again.
Ajay

> Ajay,
>
[quoted text clipped - 20 lines]
>     Me.Phone = Me.Parent.Phone
>  End If
Steve Schapel - 17 May 2007 11:10 GMT
Ajay,

I am not sure what the problem here could be.

However, please note that this idea will only work if:
- AddStaff form is a subform on the form where the Client data is current.
- The data is being entered via this subform.  Entering via the subform
if opened stand-alone, or entering directly to the table, will not work.
- This code needs to be on the Before Update event of the AddStaff
*form* itself, not the Before Update event of the textboxes on the form.

 Private Sub Form_BeforeUpdate(Cancel As Integer)
    If IsNull(Me.Phone) Then
        Me.Phone = Me.Parent.MainPhone
    End If
    If IsNull(Me.AltPhone) Then
        Me.AltPhone = Me.Parent.WorkPhone
    End If
 End Sub

Signature

Steve Schapel, Microsoft Access MVP

> Many thanks for your prompt suggestion, Steve.
> I would have preferred to have the phone numbers appear as I originally
[quoted text clipped - 19 lines]
> entering the info into other Client table as well as other Staff table
> fields.
 
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



©2009 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.