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 / New Users / June 2006

Tip: Looking for answers? Try searching our database.

option group

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JPol - 26 May 2006 19:23 GMT
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
Klatuu - 26 May 2006 19:33 GMT
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.

> 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
[quoted text clipped - 6 lines]
>
> JPol
fredg - 27 May 2006 00:38 GMT
> 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
[quoted text clipped - 6 lines]
>
> 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

Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

JPol - 27 May 2006 20:23 GMT
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 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
[quoted text clipped - 15 lines]
>     [StaffNr] = 0
> End If
Klatuu - 30 May 2006 13:39 GMT
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:
[quoted text clipped - 28 lines]
> >     [StaffNr] = 0
> > End If
JPol - 31 May 2006 23:41 GMT
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:
>
[quoted text clipped - 45 lines]
> > >     [StaffNr] = 0
> > > End If
Klatuu - 01 Jun 2006 13:45 GMT
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
[quoted text clipped - 54 lines]
> > > >     [StaffNr] = 0
> > > > End If
JPol - 01 Jun 2006 14:39 GMT
    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
[quoted text clipped - 60 lines]
> > > > >     [StaffNr] = 0
> > > > > End If
Klatuu - 01 Jun 2006 14:41 GMT
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
[quoted text clipped - 74 lines]
> > > > > >     [StaffNr] = 0
> > > > > > End If
JPol - 01 Jun 2006 16:41 GMT
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
>
[quoted text clipped - 76 lines]
> > > > > > >     [StaffNr] = 0
> > > > > > > End If
Klatuu - 01 Jun 2006 17:06 GMT
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:

> It was in before update event of the School_Date field on the
> subformAddDemerits.
[quoted text clipped - 81 lines]
> > > > > > > >     [StaffNr] = 0
> > > > > > > > End If
JPol - 02 Jun 2006 14:12 GMT
What do you mean - Break Point?

> First, check this line.  It is:
> If Not IsNull(DLookup("[School_Date]", "tabDemerits", "[School_Date]= #" &
[quoted text clipped - 97 lines]
> > > > > > > > >     [StaffNr] = 0
> > > > > > > > > End If
Klatuu - 02 Jun 2006 14:20 GMT
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.

> What do you mean - Break Point?
>
[quoted text clipped - 99 lines]
> > > > > > > > > >     [StaffNr] = 0
> > > > > > > > > > End If
 
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



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