option group

G

Guest

On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then I‘ll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol
 
G

Guest

In the After Update event of the option group:

Select Case Me.Frame25
Case 1
Me.StaffNr = 'Correct Value for Present goes here
Case 2
Me.StaffNr = 'Correct Value for Absent goes here
Case 3
Me.StaffNr = 'Corrent Value for UnExcused goes here
End Select

You can add code for any action you need to take based on value the Option
Group returns.
 
F

fredg

On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then I¡ll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol

Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If
 
G

Guest

All works great, Now next question?
Ned some help setting up the form. Have two tables:
1. Students Form and Demerits Form joined one to many
2. The demerit form is a subform with Date and I’ve placed the Option Group
box on the sub-form that has 3 buttons Present, Absent, Absent Unexcused.

When I press any of the choices I would like for the user to be unable to
duplicate the date of the attendance for the particular student. Say on
5/5/05 John Doe can be either Present, Absent or Absent Unexcused. Right now
I am able to enter records with the same date with different Option Group
choice causing duplicate date entry. Any help. Appreciate.
JPol


fredg said:
On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then Iʽll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol

Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If
 
G

Guest

In the Before Update event of the text box where you enter the date:

If Not IsNull(DLookup("[AttendanceDate]", "YourTableName", "[AttendanceDate]
= #" & Me.txtAttendanceDate & "#" Then
MsgBox "Attendance for " & Me.txtAttendanceDate & " Already Recorded"
Cancel = True
End If

[AttendanceDate] is the name of the field where the date is carried
YourTableName is the name of the table where the date is carried
Me.txtDate is the name of the text box control where you enter the date.

The code above will check to see if the date is already recorded. If the
DLookup does not return Null, that means the date is recorded. If so, the
message box will be displayed, the update will be canceled, and the cursor
will remain in the date control.


JPol said:
All works great, Now next question?
Ned some help setting up the form. Have two tables:
1. Students Form and Demerits Form joined one to many
2. The demerit form is a subform with Date and I’ve placed the Option Group
box on the sub-form that has 3 buttons Present, Absent, Absent Unexcused.

When I press any of the choices I would like for the user to be unable to
duplicate the date of the attendance for the particular student. Say on
5/5/05 John Doe can be either Present, Absent or Absent Unexcused. Right now
I am able to enter records with the same date with different Option Group
choice causing duplicate date entry. Any help. Appreciate.
JPol


fredg said:
On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then Iʽll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol

Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If
 
G

Guest

I have put the code as you have written, but gives me a error, due to
parenthesis ‘( 0r)’ not in correct place. Also lines may not be correctly
separated from line to line. Here are the names:
[AttendanceDate] is [School_Date], Table name is ‘tabDemerits’, Me.txtDate
is Me.School_Date
Could you please rewrite and post again.
Thanks
JPol


Klatuu said:
In the Before Update event of the text box where you enter the date:

If Not IsNull(DLookup("[AttendanceDate]", "YourTableName", "[AttendanceDate]
= #" & Me.txtAttendanceDate & "#" Then
MsgBox "Attendance for " & Me.txtAttendanceDate & " Already Recorded"
Cancel = True
End If

[AttendanceDate] is the name of the field where the date is carried
YourTableName is the name of the table where the date is carried
Me.txtDate is the name of the text box control where you enter the date.

The code above will check to see if the date is already recorded. If the
DLookup does not return Null, that means the date is recorded. If so, the
message box will be displayed, the update will be canceled, and the cursor
will remain in the date control.


JPol said:
All works great, Now next question?
Ned some help setting up the form. Have two tables:
1. Students Form and Demerits Form joined one to many
2. The demerit form is a subform with Date and I’ve placed the Option Group
box on the sub-form that has 3 buttons Present, Absent, Absent Unexcused.

When I press any of the choices I would like for the user to be unable to
duplicate the date of the attendance for the particular student. Say on
5/5/05 John Doe can be either Present, Absent or Absent Unexcused. Right now
I am able to enter records with the same date with different Option Group
choice causing duplicate date entry. Any help. Appreciate.
JPol


fredg said:
On Fri, 26 May 2006 11:23:01 -0700, JPol wrote:

On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then Iʽll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol

Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If
 
G

Guest

If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]
= #" & Me.txtAttendanceDate & "#") Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If



JPol said:
I have put the code as you have written, but gives me a error, due to
parenthesis ‘( 0r)’ not in correct place. Also lines may not be correctly
separated from line to line. Here are the names:
[AttendanceDate] is [School_Date], Table name is ‘tabDemerits’, Me.txtDate
is Me.School_Date
Could you please rewrite and post again.
Thanks
JPol


Klatuu said:
In the Before Update event of the text box where you enter the date:

If Not IsNull(DLookup("[AttendanceDate]", "YourTableName", "[AttendanceDate]
= #" & Me.txtAttendanceDate & "#" Then
MsgBox "Attendance for " & Me.txtAttendanceDate & " Already Recorded"
Cancel = True
End If

[AttendanceDate] is the name of the field where the date is carried
YourTableName is the name of the table where the date is carried
Me.txtDate is the name of the text box control where you enter the date.

The code above will check to see if the date is already recorded. If the
DLookup does not return Null, that means the date is recorded. If so, the
message box will be displayed, the update will be canceled, and the cursor
will remain in the date control.


JPol said:
All works great, Now next question?
Ned some help setting up the form. Have two tables:
1. Students Form and Demerits Form joined one to many
2. The demerit form is a subform with Date and I’ve placed the Option Group
box on the sub-form that has 3 buttons Present, Absent, Absent Unexcused.

When I press any of the choices I would like for the user to be unable to
duplicate the date of the attendance for the particular student. Say on
5/5/05 John Doe can be either Present, Absent or Absent Unexcused. Right now
I am able to enter records with the same date with different Option Group
choice causing duplicate date entry. Any help. Appreciate.
JPol


:

On Fri, 26 May 2006 11:23:01 -0700, JPol wrote:

On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then Iʽll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol

Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If
 
G

Guest

First I pasted it into the after update event of the School_Date field on
the form. It gave me the following error: Compile Error: Expected List
Separator or ). Then I put a list separator ) and it all looks like this:
Private Sub School_Date_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]= #" &
Me.txtAttendanceDate & "#")) Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If

It doesn’t work unfortunately,
JPol


Klatuu said:
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]
= #" & Me.txtAttendanceDate & "#") Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If



JPol said:
I have put the code as you have written, but gives me a error, due to
parenthesis ‘( 0r)’ not in correct place. Also lines may not be correctly
separated from line to line. Here are the names:
[AttendanceDate] is [School_Date], Table name is ‘tabDemerits’, Me.txtDate
is Me.School_Date
Could you please rewrite and post again.
Thanks
JPol


Klatuu said:
In the Before Update event of the text box where you enter the date:

If Not IsNull(DLookup("[AttendanceDate]", "YourTableName", "[AttendanceDate]
= #" & Me.txtAttendanceDate & "#" Then
MsgBox "Attendance for " & Me.txtAttendanceDate & " Already Recorded"
Cancel = True
End If

[AttendanceDate] is the name of the field where the date is carried
YourTableName is the name of the table where the date is carried
Me.txtDate is the name of the text box control where you enter the date.

The code above will check to see if the date is already recorded. If the
DLookup does not return Null, that means the date is recorded. If so, the
message box will be displayed, the update will be canceled, and the cursor
will remain in the date control.


:

All works great, Now next question?
Ned some help setting up the form. Have two tables:
1. Students Form and Demerits Form joined one to many
2. The demerit form is a subform with Date and I’ve placed the Option Group
box on the sub-form that has 3 buttons Present, Absent, Absent Unexcused.

When I press any of the choices I would like for the user to be unable to
duplicate the date of the attendance for the particular student. Say on
5/5/05 John Doe can be either Present, Absent or Absent Unexcused. Right now
I am able to enter records with the same date with different Option Group
choice causing duplicate date entry. Any help. Appreciate.
JPol


:

On Fri, 26 May 2006 11:23:01 -0700, JPol wrote:

On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then Iʽll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol

Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If
 
G

Guest

It goes in the Before Update event

JPol said:
First I pasted it into the after update event of the School_Date field on
the form. It gave me the following error: Compile Error: Expected List
Separator or ). Then I put a list separator ) and it all looks like this:
Private Sub School_Date_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]= #" &
Me.txtAttendanceDate & "#")) Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If

It doesn’t work unfortunately,
JPol


Klatuu said:
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]
= #" & Me.txtAttendanceDate & "#") Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If



JPol said:
I have put the code as you have written, but gives me a error, due to
parenthesis ‘( 0r)’ not in correct place. Also lines may not be correctly
separated from line to line. Here are the names:
[AttendanceDate] is [School_Date], Table name is ‘tabDemerits’, Me.txtDate
is Me.School_Date
Could you please rewrite and post again.
Thanks
JPol


:

In the Before Update event of the text box where you enter the date:

If Not IsNull(DLookup("[AttendanceDate]", "YourTableName", "[AttendanceDate]
= #" & Me.txtAttendanceDate & "#" Then
MsgBox "Attendance for " & Me.txtAttendanceDate & " Already Recorded"
Cancel = True
End If

[AttendanceDate] is the name of the field where the date is carried
YourTableName is the name of the table where the date is carried
Me.txtDate is the name of the text box control where you enter the date.

The code above will check to see if the date is already recorded. If the
DLookup does not return Null, that means the date is recorded. If so, the
message box will be displayed, the update will be canceled, and the cursor
will remain in the date control.


:

All works great, Now next question?
Ned some help setting up the form. Have two tables:
1. Students Form and Demerits Form joined one to many
2. The demerit form is a subform with Date and I’ve placed the Option Group
box on the sub-form that has 3 buttons Present, Absent, Absent Unexcused.

When I press any of the choices I would like for the user to be unable to
duplicate the date of the attendance for the particular student. Say on
5/5/05 John Doe can be either Present, Absent or Absent Unexcused. Right now
I am able to enter records with the same date with different Option Group
choice causing duplicate date entry. Any help. Appreciate.
JPol


:

On Fri, 26 May 2006 11:23:01 -0700, JPol wrote:

On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then Iʽll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol

Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If
 
G

Guest

It was in before update event of the School_Date field on the
subformAddDemerits.
It is doing nothing.
JPol

Klatuu said:
It goes in the Before Update event

JPol said:
First I pasted it into the after update event of the School_Date field on
the form. It gave me the following error: Compile Error: Expected List
Separator or ). Then I put a list separator ) and it all looks like this:
Private Sub School_Date_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]= #" &
Me.txtAttendanceDate & "#")) Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If

It doesn’t work unfortunately,
JPol


Klatuu said:
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]
= #" & Me.txtAttendanceDate & "#") Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If



:

I have put the code as you have written, but gives me a error, due to
parenthesis ‘( 0r)’ not in correct place. Also lines may not be correctly
separated from line to line. Here are the names:
[AttendanceDate] is [School_Date], Table name is ‘tabDemerits’, Me.txtDate
is Me.School_Date
Could you please rewrite and post again.
Thanks
JPol


:

In the Before Update event of the text box where you enter the date:

If Not IsNull(DLookup("[AttendanceDate]", "YourTableName", "[AttendanceDate]
= #" & Me.txtAttendanceDate & "#" Then
MsgBox "Attendance for " & Me.txtAttendanceDate & " Already Recorded"
Cancel = True
End If

[AttendanceDate] is the name of the field where the date is carried
YourTableName is the name of the table where the date is carried
Me.txtDate is the name of the text box control where you enter the date.

The code above will check to see if the date is already recorded. If the
DLookup does not return Null, that means the date is recorded. If so, the
message box will be displayed, the update will be canceled, and the cursor
will remain in the date control.


:

All works great, Now next question?
Ned some help setting up the form. Have two tables:
1. Students Form and Demerits Form joined one to many
2. The demerit form is a subform with Date and I’ve placed the Option Group
box on the sub-form that has 3 buttons Present, Absent, Absent Unexcused.

When I press any of the choices I would like for the user to be unable to
duplicate the date of the attendance for the particular student. Say on
5/5/05 John Doe can be either Present, Absent or Absent Unexcused. Right now
I am able to enter records with the same date with different Option Group
choice causing duplicate date entry. Any help. Appreciate.
JPol


:

On Fri, 26 May 2006 11:23:01 -0700, JPol wrote:

On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then Iʽll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol

Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If
 
G

Guest

First, check this line. It is:
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]= #" &
Me.School_Date & "#")) Then

I think I missed it when I rewrote the code.

Now, if that doesn't fiix it, then you need to put a breakpoint on the first
line of code in the Before Update event of School_Date. That is where the
code needs to be because you have entered a date and you want to see if it is
in the table before you allow the School_Date control to be updated.

So, set your breakpoint and step through the code checking the values of
your fields, controls, and variables.

I think it should be:

JPol said:
It was in before update event of the School_Date field on the
subformAddDemerits.
It is doing nothing.
JPol

Klatuu said:
It goes in the Before Update event

JPol said:
First I pasted it into the after update event of the School_Date field on
the form. It gave me the following error: Compile Error: Expected List
Separator or ). Then I put a list separator ) and it all looks like this:
Private Sub School_Date_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]= #" &
Me.txtAttendanceDate & "#")) Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If

It doesn’t work unfortunately,
JPol


:

If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]
= #" & Me.txtAttendanceDate & "#") Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If



:

I have put the code as you have written, but gives me a error, due to
parenthesis ‘( 0r)’ not in correct place. Also lines may not be correctly
separated from line to line. Here are the names:
[AttendanceDate] is [School_Date], Table name is ‘tabDemerits’, Me.txtDate
is Me.School_Date
Could you please rewrite and post again.
Thanks
JPol


:

In the Before Update event of the text box where you enter the date:

If Not IsNull(DLookup("[AttendanceDate]", "YourTableName", "[AttendanceDate]
= #" & Me.txtAttendanceDate & "#" Then
MsgBox "Attendance for " & Me.txtAttendanceDate & " Already Recorded"
Cancel = True
End If

[AttendanceDate] is the name of the field where the date is carried
YourTableName is the name of the table where the date is carried
Me.txtDate is the name of the text box control where you enter the date.

The code above will check to see if the date is already recorded. If the
DLookup does not return Null, that means the date is recorded. If so, the
message box will be displayed, the update will be canceled, and the cursor
will remain in the date control.


:

All works great, Now next question?
Ned some help setting up the form. Have two tables:
1. Students Form and Demerits Form joined one to many
2. The demerit form is a subform with Date and I’ve placed the Option Group
box on the sub-form that has 3 buttons Present, Absent, Absent Unexcused.

When I press any of the choices I would like for the user to be unable to
duplicate the date of the attendance for the particular student. Say on
5/5/05 John Doe can be either Present, Absent or Absent Unexcused. Right now
I am able to enter records with the same date with different Option Group
choice causing duplicate date entry. Any help. Appreciate.
JPol


:

On Fri, 26 May 2006 11:23:01 -0700, JPol wrote:

On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then Iʽll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol

Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If
 
G

Guest

What do you mean - Break Point?

Klatuu said:
First, check this line. It is:
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]= #" &
Me.School_Date & "#")) Then

I think I missed it when I rewrote the code.

Now, if that doesn't fiix it, then you need to put a breakpoint on the first
line of code in the Before Update event of School_Date. That is where the
code needs to be because you have entered a date and you want to see if it is
in the table before you allow the School_Date control to be updated.

So, set your breakpoint and step through the code checking the values of
your fields, controls, and variables.

I think it should be:

JPol said:
It was in before update event of the School_Date field on the
subformAddDemerits.
It is doing nothing.
JPol

Klatuu said:
It goes in the Before Update event

:

First I pasted it into the after update event of the School_Date field on
the form. It gave me the following error: Compile Error: Expected List
Separator or ). Then I put a list separator ) and it all looks like this:
Private Sub School_Date_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]= #" &
Me.txtAttendanceDate & "#")) Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If

It doesn’t work unfortunately,
JPol


:

If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]
= #" & Me.txtAttendanceDate & "#") Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If



:

I have put the code as you have written, but gives me a error, due to
parenthesis ‘( 0r)’ not in correct place. Also lines may not be correctly
separated from line to line. Here are the names:
[AttendanceDate] is [School_Date], Table name is ‘tabDemerits’, Me.txtDate
is Me.School_Date
Could you please rewrite and post again.
Thanks
JPol


:

In the Before Update event of the text box where you enter the date:

If Not IsNull(DLookup("[AttendanceDate]", "YourTableName", "[AttendanceDate]
= #" & Me.txtAttendanceDate & "#" Then
MsgBox "Attendance for " & Me.txtAttendanceDate & " Already Recorded"
Cancel = True
End If

[AttendanceDate] is the name of the field where the date is carried
YourTableName is the name of the table where the date is carried
Me.txtDate is the name of the text box control where you enter the date.

The code above will check to see if the date is already recorded. If the
DLookup does not return Null, that means the date is recorded. If so, the
message box will be displayed, the update will be canceled, and the cursor
will remain in the date control.


:

All works great, Now next question?
Ned some help setting up the form. Have two tables:
1. Students Form and Demerits Form joined one to many
2. The demerit form is a subform with Date and I’ve placed the Option Group
box on the sub-form that has 3 buttons Present, Absent, Absent Unexcused.

When I press any of the choices I would like for the user to be unable to
duplicate the date of the attendance for the particular student. Say on
5/5/05 John Doe can be either Present, Absent or Absent Unexcused. Right now
I am able to enter records with the same date with different Option Group
choice causing duplicate date entry. Any help. Appreciate.
JPol


:

On Fri, 26 May 2006 11:23:01 -0700, JPol wrote:

On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then Iʽll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol

Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If
 
G

Guest

Open the code module in the VB editor. Put your cursor on the first line of
executable code in the procedure you want to debug. Press F9. You will see
the line change color. That means when the code is called, it will stop on
this line and it will be highlighted. To execute the line, press F8. You
can also position your cursor over a variable and be able to see the value.
You can also add Watches, which will present a window to allow you to see the
value of all objects.
You can step through the code line at a time to see what it is doing and
know exactly which line an error occurs on.

JPol said:
What do you mean - Break Point?

Klatuu said:
First, check this line. It is:
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]= #" &
Me.School_Date & "#")) Then

I think I missed it when I rewrote the code.

Now, if that doesn't fiix it, then you need to put a breakpoint on the first
line of code in the Before Update event of School_Date. That is where the
code needs to be because you have entered a date and you want to see if it is
in the table before you allow the School_Date control to be updated.

So, set your breakpoint and step through the code checking the values of
your fields, controls, and variables.

I think it should be:

JPol said:
It was in before update event of the School_Date field on the
subformAddDemerits.
It is doing nothing.
JPol

:

It goes in the Before Update event

:

First I pasted it into the after update event of the School_Date field on
the form. It gave me the following error: Compile Error: Expected List
Separator or ). Then I put a list separator ) and it all looks like this:
Private Sub School_Date_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]= #" &
Me.txtAttendanceDate & "#")) Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If

It doesn’t work unfortunately,
JPol


:

If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]
= #" & Me.txtAttendanceDate & "#") Then
MsgBox "Attendance for " & Me.School_Date & " Already Recorded"
Cancel = True
End If



:

I have put the code as you have written, but gives me a error, due to
parenthesis ‘( 0r)’ not in correct place. Also lines may not be correctly
separated from line to line. Here are the names:
[AttendanceDate] is [School_Date], Table name is ‘tabDemerits’, Me.txtDate
is Me.School_Date
Could you please rewrite and post again.
Thanks
JPol


:

In the Before Update event of the text box where you enter the date:

If Not IsNull(DLookup("[AttendanceDate]", "YourTableName", "[AttendanceDate]
= #" & Me.txtAttendanceDate & "#" Then
MsgBox "Attendance for " & Me.txtAttendanceDate & " Already Recorded"
Cancel = True
End If

[AttendanceDate] is the name of the field where the date is carried
YourTableName is the name of the table where the date is carried
Me.txtDate is the name of the text box control where you enter the date.

The code above will check to see if the date is already recorded. If the
DLookup does not return Null, that means the date is recorded. If so, the
message box will be displayed, the update will be canceled, and the cursor
will remain in the date control.


:

All works great, Now next question?
Ned some help setting up the form. Have two tables:
1. Students Form and Demerits Form joined one to many
2. The demerit form is a subform with Date and I’ve placed the Option Group
box on the sub-form that has 3 buttons Present, Absent, Absent Unexcused.

When I press any of the choices I would like for the user to be unable to
duplicate the date of the attendance for the particular student. Say on
5/5/05 John Doe can be either Present, Absent or Absent Unexcused. Right now
I am able to enter records with the same date with different Option Group
choice causing duplicate date entry. Any help. Appreciate.
JPol


:

On Fri, 26 May 2006 11:23:01 -0700, JPol wrote:

On my form I have an option group[Frame25] set to Present(1), Absent(2),
Unexcused(3). Present is a default. There are other fields on the form that I
would like to behave depending on which option in an Option Group was chosen.
If I know how to program one of the them then Iʽll repeat the procedure for
others in like manner.

The field [StaffNr] needs to do the following:
If Frame25= Present then default, If Absent=[HomeroomNr], if unexcused then 0

JPol

Code Frame25 AfterUpdate event:
If Me![Frame25] = 1 Then
[StaffNr] = [StaffNr].defaultvalue
Elseif Me![Frame25] = 2 then
[StaffNr] = Me![HomeroomNr]
Else
[StaffNr] = 0
End If
 

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

Top