How to open form for selected value??

R

Ron

I have a form, frmFaculty that has a listbox that lists all courses
that this faculty member teaches. When they select a course from the
listbox and click a button I want a form to pop up called
frmEnrollment, this form will show all the students that are
registered for this course that was selected. Course that is selected
is known by the scheduleNO. And each student is also associated with a
scheduleNo.

Here is what I have in the Click even of the button to view enrollment.
Dim strselction As String
Dim inti As Integer
strselection = "[Scheduleno]=("
For inti = 0 To (List6.ListCount - 1)

If List6.Selected(inti) Then
strwhere = strselection & "'" & List6.Column(0, inti) & "'" & ")"
MsgBox strwhere
End If
Next inti

DoCmd.OpenForm "frmenrollment", acNormal, , strwhere

And in the debugger if I MOUSE OVER strwhere, it shows [scheduleno=
112553 <---or whatever the actual number that is selected.

so basically I just want to open up frmEnroll for the selected
scheduleno. so if 1112223 is selected I want all 1112223 entries to
come up on the next form.

Any ideas?
Right now I get a error the Openform action was cancelled
 
D

Duane Hookom

If your list box is single selection then just try code like:
Dim strselction As String
Dim inti As Integer
strwhere = "[Scheduleno]=" & Me.List6
DoCmd.OpenForm "frmenrollment", acNormal, , strwhere
If ScheduleNo is text then use:
strwhere = "[Scheduleno]=""" & Me.List6 & """"
 
R

Ron

that did the trick, thanks.

What if I add a textbox to that frmEnrollment called txtGrade and next
to each student that comes up I want to enter a grade for example A, B,
C.... and then I want to insert that grade into my enrollment table
under the field GRADE.

So right now my Enrollment table has fields ScheduleNo and StudentID.
and a blank field GRADE. next to each studentID and ScheduleNo I want
to insert a grade, the grade will come from txtgrade on frmEnroll for
that particular studentid and scheduleNo

How would I do something like this?

Duane said:
If your list box is single selection then just try code like:
Dim strselction As String
Dim inti As Integer
strwhere = "[Scheduleno]=" & Me.List6
DoCmd.OpenForm "frmenrollment", acNormal, , strwhere
If ScheduleNo is text then use:
strwhere = "[Scheduleno]=""" & Me.List6 & """"

--
Duane Hookom
MS Access MVP

Ron said:
I have a form, frmFaculty that has a listbox that lists all courses
that this faculty member teaches. When they select a course from the
listbox and click a button I want a form to pop up called
frmEnrollment, this form will show all the students that are
registered for this course that was selected. Course that is selected
is known by the scheduleNO. And each student is also associated with a
scheduleNo.

Here is what I have in the Click even of the button to view enrollment.
Dim strselction As String
Dim inti As Integer
strselection = "[Scheduleno]=("
For inti = 0 To (List6.ListCount - 1)

If List6.Selected(inti) Then
strwhere = strselection & "'" & List6.Column(0, inti) & "'" & ")"
MsgBox strwhere
End If
Next inti

DoCmd.OpenForm "frmenrollment", acNormal, , strwhere

And in the debugger if I MOUSE OVER strwhere, it shows [scheduleno=
112553 <---or whatever the actual number that is selected.

so basically I just want to open up frmEnroll for the selected
scheduleno. so if 1112223 is selected I want all 1112223 entries to
come up on the next form.

Any ideas?
Right now I get a error the Openform action was cancelled
[/QUOTE]
 
D

Duane Hookom

I don't know your table structures or form recordsources. Why can't you just
add the GRADE field to the opened form?

--
Duane Hookom
MS Access MVP

Ron said:
that did the trick, thanks.

What if I add a textbox to that frmEnrollment called txtGrade and next
to each student that comes up I want to enter a grade for example A, B,
C.... and then I want to insert that grade into my enrollment table
under the field GRADE.

So right now my Enrollment table has fields ScheduleNo and StudentID.
and a blank field GRADE. next to each studentID and ScheduleNo I want
to insert a grade, the grade will come from txtgrade on frmEnroll for
that particular studentid and scheduleNo

How would I do something like this?

Duane said:
If your list box is single selection then just try code like:
Dim strselction As String
Dim inti As Integer
strwhere = "[Scheduleno]=" & Me.List6
DoCmd.OpenForm "frmenrollment", acNormal, , strwhere
If ScheduleNo is text then use:
strwhere = "[Scheduleno]=""" & Me.List6 & """"

--
Duane Hookom
MS Access MVP

Ron said:
I have a form, frmFaculty that has a listbox that lists all courses
that this faculty member teaches. When they select a course from the
listbox and click a button I want a form to pop up called
frmEnrollment, this form will show all the students that are
registered for this course that was selected. Course that is selected
is known by the scheduleNO. And each student is also associated with a
scheduleNo.

Here is what I have in the Click even of the button to view enrollment.
Dim strselction As String
Dim inti As Integer
strselection = "[Scheduleno]=("
For inti = 0 To (List6.ListCount - 1)

If List6.Selected(inti) Then
strwhere = strselection & "'" & List6.Column(0, inti) & "'" & ")"
MsgBox strwhere
End If
Next inti

DoCmd.OpenForm "frmenrollment", acNormal, , strwhere

And in the debugger if I MOUSE OVER strwhere, it shows [scheduleno=
112553 <---or whatever the actual number that is selected.

so basically I just want to open up frmEnroll for the selected
scheduleno. so if 1112223 is selected I want all 1112223 entries to
come up on the next form.

Any ideas?
Right now I get a error the Openform action was cancelled
[/QUOTE]
 
R

Ron

I can and thats what I am doing, next to each record on the open form
I am entering the grade, I then want to record that grade in the
enrollment table.

so for example my open form looks like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201 B (this grade is a textbox that
will get entered)
11332001 77112010 B

My Enrollment table looks like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201
11332001 77112010

So I just want to add the grade that I input into the textbox on the
openform to the corresponding row in the table.

so after the button is pressed, I want the enrollment table to look
like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201 B
11332001 77112010 B





Duane said:
I don't know your table structures or form recordsources. Why can't you just
add the GRADE field to the opened form?

--
Duane Hookom
MS Access MVP

Ron said:
that did the trick, thanks.

What if I add a textbox to that frmEnrollment called txtGrade and next
to each student that comes up I want to enter a grade for example A, B,
C.... and then I want to insert that grade into my enrollment table
under the field GRADE.

So right now my Enrollment table has fields ScheduleNo and StudentID.
and a blank field GRADE. next to each studentID and ScheduleNo I want
to insert a grade, the grade will come from txtgrade on frmEnroll for
that particular studentid and scheduleNo

How would I do something like this?

Duane said:
If your list box is single selection then just try code like:
Dim strselction As String
Dim inti As Integer
strwhere = "[Scheduleno]=" & Me.List6
DoCmd.OpenForm "frmenrollment", acNormal, , strwhere
If ScheduleNo is text then use:
strwhere = "[Scheduleno]=""" & Me.List6 & """"

--
Duane Hookom
MS Access MVP

I have a form, frmFaculty that has a listbox that lists all courses
that this faculty member teaches. When they select a course from the
listbox and click a button I want a form to pop up called
frmEnrollment, this form will show all the students that are
registered for this course that was selected. Course that is selected
is known by the scheduleNO. And each student is also associated with a
scheduleNo.

Here is what I have in the Click even of the button to view enrollment.
Dim strselction As String
Dim inti As Integer
strselection = "[Scheduleno]=("
For inti = 0 To (List6.ListCount - 1)

If List6.Selected(inti) Then
strwhere = strselection & "'" & List6.Column(0, inti) & "'" & ")"
MsgBox strwhere
End If
Next inti

DoCmd.OpenForm "frmenrollment", acNormal, , strwhere

And in the debugger if I MOUSE OVER strwhere, it shows [scheduleno=
112553 <---or whatever the actual number that is selected.

so basically I just want to open up frmEnroll for the selected
scheduleno. so if 1112223 is selected I want all 1112223 entries to
come up on the next form.

Any ideas?
Right now I get a error the Openform action was cancelled
[/QUOTE]
 
D

Duane Hookom

What is the record source of "my open form"? Isn't it "My Enrollment table"?

--
Duane Hookom
MS Access MVP

Ron said:
I can and thats what I am doing, next to each record on the open form
I am entering the grade, I then want to record that grade in the
enrollment table.

so for example my open form looks like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201 B (this grade is a textbox that
will get entered)
11332001 77112010 B

My Enrollment table looks like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201
11332001 77112010

So I just want to add the grade that I input into the textbox on the
openform to the corresponding row in the table.

so after the button is pressed, I want the enrollment table to look
like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201 B
11332001 77112010 B





Duane said:
I don't know your table structures or form recordsources. Why can't you
just
add the GRADE field to the opened form?

--
Duane Hookom
MS Access MVP

Ron said:
that did the trick, thanks.

What if I add a textbox to that frmEnrollment called txtGrade and next
to each student that comes up I want to enter a grade for example A, B,
C.... and then I want to insert that grade into my enrollment table
under the field GRADE.

So right now my Enrollment table has fields ScheduleNo and StudentID.
and a blank field GRADE. next to each studentID and ScheduleNo I want
to insert a grade, the grade will come from txtgrade on frmEnroll for
that particular studentid and scheduleNo

How would I do something like this?

Duane Hookom wrote:
If your list box is single selection then just try code like:
Dim strselction As String
Dim inti As Integer
strwhere = "[Scheduleno]=" & Me.List6
DoCmd.OpenForm "frmenrollment", acNormal, , strwhere
If ScheduleNo is text then use:
strwhere = "[Scheduleno]=""" & Me.List6 & """"

--
Duane Hookom
MS Access MVP

I have a form, frmFaculty that has a listbox that lists all courses
that this faculty member teaches. When they select a course from the
listbox and click a button I want a form to pop up called
frmEnrollment, this form will show all the students that are
registered for this course that was selected. Course that is
selected
is known by the scheduleNO. And each student is also associated
with a
scheduleNo.

Here is what I have in the Click even of the button to view
enrollment.
Dim strselction As String
Dim inti As Integer
strselection = "[Scheduleno]=("
For inti = 0 To (List6.ListCount - 1)

If List6.Selected(inti) Then
strwhere = strselection & "'" & List6.Column(0, inti) & "'" & ")"
MsgBox strwhere
End If
Next inti

DoCmd.OpenForm "frmenrollment", acNormal, , strwhere

And in the debugger if I MOUSE OVER strwhere, it shows [scheduleno=
112553 <---or whatever the actual number that is selected.

so basically I just want to open up frmEnroll for the selected
scheduleno. so if 1112223 is selected I want all 1112223 entries to
come up on the next form.

Any ideas?
Right now I get a error the Openform action was cancelled
[/QUOTE]
 
R

Ron

no its a query

Duane said:
What is the record source of "my open form"? Isn't it "My Enrollment table"?

--
Duane Hookom
MS Access MVP

Ron said:
I can and thats what I am doing, next to each record on the open form
I am entering the grade, I then want to record that grade in the
enrollment table.

so for example my open form looks like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201 B (this grade is a textbox that
will get entered)
11332001 77112010 B

My Enrollment table looks like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201
11332001 77112010

So I just want to add the grade that I input into the textbox on the
openform to the corresponding row in the table.

so after the button is pressed, I want the enrollment table to look
like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201 B
11332001 77112010 B





Duane said:
I don't know your table structures or form recordsources. Why can't you
just
add the GRADE field to the opened form?

--
Duane Hookom
MS Access MVP

that did the trick, thanks.

What if I add a textbox to that frmEnrollment called txtGrade and next
to each student that comes up I want to enter a grade for example A, B,
C.... and then I want to insert that grade into my enrollment table
under the field GRADE.

So right now my Enrollment table has fields ScheduleNo and StudentID.
and a blank field GRADE. next to each studentID and ScheduleNo I want
to insert a grade, the grade will come from txtgrade on frmEnroll for
that particular studentid and scheduleNo

How would I do something like this?

Duane Hookom wrote:
If your list box is single selection then just try code like:
Dim strselction As String
Dim inti As Integer
strwhere = "[Scheduleno]=" & Me.List6
DoCmd.OpenForm "frmenrollment", acNormal, , strwhere
If ScheduleNo is text then use:
strwhere = "[Scheduleno]=""" & Me.List6 & """"

--
Duane Hookom
MS Access MVP

I have a form, frmFaculty that has a listbox that lists all courses
that this faculty member teaches. When they select a course from the
listbox and click a button I want a form to pop up called
frmEnrollment, this form will show all the students that are
registered for this course that was selected. Course that is
selected
is known by the scheduleNO. And each student is also associated
with a
scheduleNo.

Here is what I have in the Click even of the button to view
enrollment.
Dim strselction As String
Dim inti As Integer
strselection = "[Scheduleno]=("
For inti = 0 To (List6.ListCount - 1)

If List6.Selected(inti) Then
strwhere = strselection & "'" & List6.Column(0, inti) & "'" & ")"
MsgBox strwhere
End If
Next inti

DoCmd.OpenForm "frmenrollment", acNormal, , strwhere

And in the debugger if I MOUSE OVER strwhere, it shows [scheduleno=
112553 <---or whatever the actual number that is selected.

so basically I just want to open up frmEnroll for the selected
scheduleno. so if 1112223 is selected I want all 1112223 entries to
come up on the next form.

Any ideas?
Right now I get a error the Openform action was cancelled
[/QUOTE]
 
D

Duane Hookom

If it is a query, then what table(s) is it based on and why can't you include
the Grade field in the query?

--
Duane Hookom
Microsoft Access MVP


Ron said:
no its a query

Duane said:
What is the record source of "my open form"? Isn't it "My Enrollment table"?

--
Duane Hookom
MS Access MVP

Ron said:
I can and thats what I am doing, next to each record on the open form
I am entering the grade, I then want to record that grade in the
enrollment table.

so for example my open form looks like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201 B (this grade is a textbox that
will get entered)
11332001 77112010 B

My Enrollment table looks like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201
11332001 77112010

So I just want to add the grade that I input into the textbox on the
openform to the corresponding row in the table.

so after the button is pressed, I want the enrollment table to look
like this:
STUDENTID SCHEDULENO GRADE
==============================
11112222 99911201 B
11332001 77112010 B





Duane Hookom wrote:
I don't know your table structures or form recordsources. Why can't you
just
add the GRADE field to the opened form?

--
Duane Hookom
MS Access MVP

that did the trick, thanks.

What if I add a textbox to that frmEnrollment called txtGrade and next
to each student that comes up I want to enter a grade for example A, B,
C.... and then I want to insert that grade into my enrollment table
under the field GRADE.

So right now my Enrollment table has fields ScheduleNo and StudentID.
and a blank field GRADE. next to each studentID and ScheduleNo I want
to insert a grade, the grade will come from txtgrade on frmEnroll for
that particular studentid and scheduleNo

How would I do something like this?

Duane Hookom wrote:
If your list box is single selection then just try code like:
Dim strselction As String
Dim inti As Integer
strwhere = "[Scheduleno]=" & Me.List6
DoCmd.OpenForm "frmenrollment", acNormal, , strwhere
If ScheduleNo is text then use:
strwhere = "[Scheduleno]=""" & Me.List6 & """"

--
Duane Hookom
MS Access MVP

I have a form, frmFaculty that has a listbox that lists all courses
that this faculty member teaches. When they select a course from the
listbox and click a button I want a form to pop up called
frmEnrollment, this form will show all the students that are
registered for this course that was selected. Course that is
selected
is known by the scheduleNO. And each student is also associated
with a
scheduleNo.

Here is what I have in the Click even of the button to view
enrollment.
Dim strselction As String
Dim inti As Integer
strselection = "[Scheduleno]=("
For inti = 0 To (List6.ListCount - 1)

If List6.Selected(inti) Then
strwhere = strselection & "'" & List6.Column(0, inti) & "'" & ")"
MsgBox strwhere
End If
Next inti

DoCmd.OpenForm "frmenrollment", acNormal, , strwhere

And in the debugger if I MOUSE OVER strwhere, it shows [scheduleno=
112553 <---or whatever the actual number that is selected.

so basically I just want to open up frmEnroll for the selected
scheduleno. so if 1112223 is selected I want all 1112223 entries to
come up on the next form.

Any ideas?
Right now I get a error the Openform action was cancelled
[/QUOTE]
 

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