Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to transfer data from field on form to other form? 1

Status
Not open for further replies.

ffleitas

Technical User
Mar 15, 2001
85
US
Hello programmers,

I have a form frmform1 and inside is frmform2. frmform2 has 7 check boxes Monday - Sunday. If I select Monday then press a command button to open another form I would like the transfer of chk box monday's YES criteria to display on the newly opened form. This is what I have in VB:

Private Sub Form_Open(Cancel As Integer)

If Forms![frmform2].Form![Monday] = Yes Then
[Date2] = Date - Weekday(Date) + 2
End If

If Forms![frmform2].Form![Tuesday] = Yes Then
[Date2] = Date - Weekday(Date) + 3
End If

If Forms![frmform2].Form![Wednesday] = YES Then
[Date2] = Date - Weekday(Date) + 4
End If

If Forms![frmform2].Form![Thursday] = YES Then
[Date2] = Date - Weekday(Date) + 5
End If

If Forms![frmform2].Form![Friday] = YES
[Date2] = Date - Weekday(Date) + 6
End If

If Forms![frmform2].Form![Saturday] = YES
[Date2] = Date - Weekday(Date) + 7
End If

If Forms![frmform2].Form![Sunday] = YES
[Date2] = Date - Weekday(Date) + 8
End If

End Sub

The problem is:
The data transfers to the field but only the last if condition of Sunday. Eventhough I choose Monday or Tuesday, etc. How can I repair this function?
 
I suggest modify your form and replace the check boxes for Option Button(even you can make that look like checkbox)

The easiest way is make a new frame with the wizard enable, then enter the values Monday..Sunday an select the aspect. Also you don't need to validate if the user has selected only one choice.

If you do that each option has a value between 1 and 7. You only need to pass the value to the new form. In the launch button put the code:

Code:
DoCmd.OpenForm "Form2", , , , , ,DayOption

Where DayOption is the value is the frame name. Also you can open the form with other arguments.

In Form2 code On Open Event put

Day=Me.Openargs

Where Day is a Private variable. Then you can do what you want whit day.

Greetings from Chile

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top