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 2008

Tip: Looking for answers? Try searching our database.

Button Click Event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fireytech@gmail.com - 18 Jun 2008 23:42 GMT
I have created a launch form which asks the user to enter the
datepayperiod (pay period end date) and their vendorID (employee
number).  I have created a button for them to click to open our time
sheet form (frm_timesheet) and automatically carry the pay period date
and the vendorid to the new form.  I did this to prevent the user from
editing the pay period date or their vendorid fields on the data entry
form.

I know how to make the form take one field and carry it to the new
form but I don't know how to make it carry both the datepayperiod and
vendorid fields to the data entry form.

Here is the code I have so far:

Private Sub CreateNewTimesheet_Click()
On Error GoTo Err_CreateNewTimesheet_Click

   Dim stDocName As String
   Dim stLinkCriteria As String

   stDocName = "FRM_Timesheet"
   DoCmd.OpenForm stDocName, , , acFormAdd
   Forms(stDocName)![VendorID] = Me.[VendorID]
Exit_CreateNewTimesheet_Click:
   Exit Sub

Err_CreateNewTimesheet_Click:
   MsgBox Err.Description
   Resume Exit_CreateNewTimesheet_Click
End Sub

Thanks in advance!
Ken Snell (MVP) - 19 Jun 2008 01:50 GMT
I assume that this step is what you mean by "carrying" the value to the
newly opened form:

   Forms(stDocName)![VendorID] = Me.[VendorID]

If this is what you mean, just add a second code line that assigns the
desired pay period date to the appropriate control on the newly opened form.
Signature


       Ken Snell
<MS ACCESS MVP>

>I have created a launch form which asks the user to enter the
> datepayperiod (pay period end date) and their vendorID (employee
[quoted text clipped - 28 lines]
>
> Thanks in advance!
fireytech@gmail.com - 19 Jun 2008 13:44 GMT
Yes, this line is the line which "carries" the vendorid to the data
entry form.  I know that I need additional code to "carry" the
payperiod date forward as well.  That is what I need help with.  I
don't know how to do that.  Please help further.
Ken Snell (MVP) - 21 Jun 2008 04:43 GMT
Maybe I am missing something here, but this should work:

   Forms(stDocName)![NameOfControlForPayPeriodDate] =
Me.[PayPeriodDateFieldOrControl]

Signature

       Ken Snell
<MS ACCESS MVP>

> Yes, this line is the line which "carries" the vendorid to the data
> entry form.  I know that I need additional code to "carry" the
> payperiod date forward as well.  That is what I need help with.  I
> don't know how to do that.  Please help further.
fireytech@gmail.com - 24 Jun 2008 23:08 GMT
Here is what I put in and it still just opens the form and enters the
vendorID only.  The payperiod field stays blank:

Private Sub CreateNewTimesheet_Click()
On Error GoTo Err_CreateNewTimesheet_Click

   Dim stDocName As String
   Dim stLinkCriteria As String

   stDocName = "FRM_Timesheet"
   DoCmd.OpenForm stDocName, , , acFormAdd
   Forms(stDocName)![VendorID] = Me.[VendorID]
   Forms(stDocName)![PayPeriod] = Me.[PayPeriod]
Exit_CreateNewTimesheet_Click:
   Exit Sub

Err_CreateNewTimesheet_Click:
   MsgBox Err.Description
   Resume Exit_CreateNewTimesheet_Click
End Sub
Ken Snell (MVP) - 25 Jun 2008 02:56 GMT
Does the Me.[PayPeriod] control/field actually have a value? Is it a control
or a field? If a field, are you saving the record that is associated with
that field before clicking the button to open the second form?

What datatype is the PayPeriod control/form? What is its Format property?
Same two questions for the PayPeriod control/field on the second form.

Is an error occurring in your code on this step, such that your error
handler is being called and thus the value isn't being set in your second
form?
   Forms(stDocName)![PayPeriod] = Me.[PayPeriod]

Signature

       Ken Snell
<MS ACCESS MVP>

> Here is what I put in and it still just opens the form and enters the
> vendorID only.  The payperiod field stays blank:
[quoted text clipped - 16 lines]
>    Resume Exit_CreateNewTimesheet_Click
> End Sub
fireytech@gmail.com - 26 Jun 2008 22:00 GMT
the "payperiod" is a field in the table that both forms use.  there
will be data present in the timesheetlaunch form but not present in
the form we are going to until we move it.  I don't think the record
is saving when the button is clicked so maybe that is part of the
problem?

payperiod data is structured as date/time

the last question about the error.  it is popping the error when the
form opens.  if i just use the form by itself without clicking the
button to get to it is the same.
Ken Snell (MVP) - 28 Jun 2008 22:57 GMT
I am traveling for work, which is delaying my reply to your post. I'll post
as soon as I can.
Signature


       Ken Snell
<MS ACCESS MVP>

> the "payperiod" is a field in the table that both forms use.  there
> will be data present in the timesheetlaunch form but not present in
[quoted text clipped - 7 lines]
> form opens.  if i just use the form by itself without clicking the
> button to get to it is the same.
Ken Snell (MVP) - 01 Jul 2008 03:16 GMT
Am I understanding correctly? You're entering a value for the payperiod on
the form and then clicking the button to carry that value to the second
form? Where on the form is the button located -- in which section of the
form? Is the form on which you're entering the payperiod data a continuous
forms view or single forms view?

What is the name of the form's control that holds the entered payperiod
value?

It would appear to me that the form cannot "see" the data value and thus is
not able to carry it to the other form. Please provide as much detail about
the form and what you do on the form before clicking the button.

Signature

       Ken Snell
<MS ACCESS MVP>

> the "payperiod" is a field in the table that both forms use.  there
> will be data present in the timesheetlaunch form but not present in
[quoted text clipped - 7 lines]
> form opens.  if i just use the form by itself without clicking the
> button to get to it is the same.
 
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.