Autopopulating Field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I made a subform that has a button in it that when clicked will open a
different form in a new window. The subform contains a different record for
each service for the specific person listed in the main form. The button
opens a form where I can enter specific billing info every month for the
specific service number that is currently displayed. I have a table for
"services" and a table for "monthly billing" and each contain a field called
"service number". I have these 2 tables linked together by this field in the
relationships windows.

What I want to do is when I click on that button is bring up the form to
enter the specific billing details for the service number that is currently
displayed. When I do this though, the service number field in the "monthly
billing" table is not entered in automatically.

I am a beginning Access user and would like to know how to do this.

Thank You,

CEV
 
CEV said:
Hi, I made a subform that has a button in it that when clicked will
open a different form in a new window. The subform contains a
different record for each service for the specific person listed in
the main form. The button opens a form where I can enter specific
billing info every month for the specific service number that is
currently displayed. I have a table for "services" and a table for
"monthly billing" and each contain a field called "service number". I
have these 2 tables linked together by this field in the
relationships windows.
What I want to do is when I click on that button is bring up the form
to enter the specific billing details for the service number that is
currently displayed. When I do this though, the service number field
in the "monthly billing" table is not entered in automatically.

I am a beginning Access user and would like to know how to do this.

Thank You,

CEV

A quick guess is you will need to pick an event (like form open) and use
that to trigger and event to cause FORM2SERVICENUMBER=FORM1SERVICENUMBER.
Change the names to fit your application.
 
Thanks for the response. But now where do i do this at? And do I enter it
exactly like that but with the actual name of my forms?

Thanks,

CEV
 
CEV said:
Thanks for the response. But now where do i do this at? And do I
enter it exactly like that but with the actual name of my forms?

First you need to find an "event" that takes place anytime you want to
do the copy. You also want to pick an event that will not take place when
you don't want to copy the data. Look at the properties of the event and
you should be able to figure out where to put it.

Notes: Copying data is often not a good idea. If you have data one
place, more often than not, you should just refer to it when ever you need
it rather than copying and saving it somewhere else. Not only is it more
efficient for Access, it also means the data will always be up to date, If
you copy and for some reason it gets changed, the copy does not get changed.

You will want to make sure that you identify the specific source and
destination. Doing that depends on what they are. I am not sure what the
relationship (database relationship) is between the two fields so that could
enter in when writing the code. It tends to be application specific.
 
Hi, I made a subform that has a button in it that when clicked will open a
different form in a new window. The subform contains a different record for
each service for the specific person listed in the main form. The button
opens a form where I can enter specific billing info every month for the
specific service number that is currently displayed. I have a table for
"services" and a table for "monthly billing" and each contain a field called
"service number". I have these 2 tables linked together by this field in the
relationships windows.

What I want to do is when I click on that button is bring up the form to
enter the specific billing details for the service number that is currently
displayed. When I do this though, the service number field in the "monthly
billing" table is not entered in automatically.

I am a beginning Access user and would like to know how to do this.

Thank You,

CEV

An additional approach to Joseph's solution (which one is more
appropriate depends on the situation) is to pass the Service Number in
the OpenArgs argument of the OpenForm method, and use the Form's Open
event to set the DefaultValue property of a control:

Dim strFormname As String
Dim strCriteria As String
strFormName = "YourSpecificForm"
strCriteria = "[Service Number] = " & Me![Service Number]
DoCmd.OpenForm strCriteria, WhereCondition := strCriteria, _
OpenArgs = Me![Service Number]
<more code>

and in YourSpecificForm's Open event

Private Sub Form_Open(Cancel as Integer)
If Me.OpenArgs & "" <> "" Then ' was an Openargs passed?
Me!txtServiceNumber.DefaultValue = Chr(34) & Me.OpenArgs & Chr(34)
End If
End Sub

Thus if the calling form's ServiceNumber is 123, the DefaultValue
property of the textbox txtServiceNumber will be set to

"123"

and new records created on the form will pick up 123 as their value.

John W. Vinson[MVP]
 

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

Back
Top