By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,519 Members | 1,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,519 IT Pros & Developers. It's quick & easy.

Cannot Set Bound TextBox Value

P: n/a
Hello,
I have an MS Access 2003 Project form in which I need to set the value
of a textbox named 'TestGrade' to the value present after the update
of a combo box currently named 'Combo6'. The data source for the
project is a SQL Server 2000 database.

I have the following code written for the 'After Update' event of
'Combo6'

Private Sub Combo6_AfterUpdate()
If IsNull(Me.TestGrade) Then
DoCmd.GoToControl ("TestGrade")
Me.TestGrade.Value = "Exec dbo.MMFindStudentGrade_sp" & Me.Combo6
End If
End Sub

The 'MMFindStudentGrade_sp' is designed to take a StudentID (Permnum)
parameter, and return the grade level of the student. The bound field
'TestGrade' is of type 'smallint'. The bound column of 'Combo6' is the
studentID. The combo box is supposed to pass the studentID value to
the procedure, and 'TestGrade' is then supposed to be populated with
the student's grade level that the procedure returns.

When I tried to test this the first time, I got an error message back
stating that the control I was trying to populate had to have the
focus. After adding the 'DoCmd.GoToContol' statement, I tested combo6
again, and got RunTime error 2113 'The value you entered is not valid
for this control'.

The following is the code for the procedure:
****************************
alter Procedure MMFindStudentGrade_sp
@Permnum varchar(12)
AS
Select Cast(Right(Grade,1)as smallint)
From Student_Data_Main
Where
Permnum=@Permnum

exec MMFindStudentGrade_sp
@Permnum = 602
**************************

I have done this type of value assignment between combo boxes, but not
from a combo box to a text box before.

How can I modify this code so that the bound text box called
'TestGrade' can be populated with the results of
'MMFindStudentGrade_sp' after Combo6 updates?

Thank you for your help!

CSDunn
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Am Mon, 12 Jul 2004 17:08:07 -0700 schrieb CSDunn:
Hello,
I have an MS Access 2003 Project form in which I need to set the value
of a textbox named 'TestGrade' to the value present after the update
of a combo box currently named 'Combo6'. The data source for the
project is a SQL Server 2000 database.

I have the following code written for the 'After Update' event of
'Combo6'

Private Sub Combo6_AfterUpdate()
If IsNull(Me.TestGrade) Then
DoCmd.GoToControl ("TestGrade")
Me.TestGrade.Value = "Exec dbo.MMFindStudentGrade_sp" & Me.Combo6
End If
End Sub

The 'MMFindStudentGrade_sp' is designed to take a StudentID (Permnum)
parameter, and return the grade level of the student. The bound field
'TestGrade' is of type 'smallint'. The bound column of 'Combo6' is the
studentID. The combo box is supposed to pass the studentID value to
the procedure, and 'TestGrade' is then supposed to be populated with
the student's grade level that the procedure returns.

When I tried to test this the first time, I got an error message back
stating that the control I was trying to populate had to have the
focus. After adding the 'DoCmd.GoToContol' statement, I tested combo6
again, and got RunTime error 2113 'The value you entered is not valid
for this control'.

The following is the code for the procedure:
****************************
alter Procedure MMFindStudentGrade_sp
@Permnum varchar(12)
AS
Select Cast(Right(Grade,1)as smallint)
From Student_Data_Main
Where
Permnum=@Permnum

exec MMFindStudentGrade_sp
@Permnum = 602
**************************

I have done this type of value assignment between combo boxes, but not
from a combo box to a text box before.

How can I modify this code so that the bound text box called
'TestGrade' can be populated with the results of
'MMFindStudentGrade_sp' after Combo6 updates?

Thank you for your help!

CSDunn


Hello,

it's not so easy.

You have to use the Command-Object and retrieve the grade Value from
this object. Access has some help on the Command-Object.

HTH
Karpi
<fluctuat nec mergitur>
Nov 13 '05 #2

P: n/a
Yes, that's what I found out! I was able to find a solution on an Access VBA site.

Thank you for following up!

Chris Dunn

Hans-Joerg Karpenstein <hj***********@web.de> wrote in message news:<pa****************************@web.de>...
Am Mon, 12 Jul 2004 17:08:07 -0700 schrieb CSDunn:
Hello,
I have an MS Access 2003 Project form in which I need to set the value
of a textbox named 'TestGrade' to the value present after the update
of a combo box currently named 'Combo6'. The data source for the
project is a SQL Server 2000 database.

I have the following code written for the 'After Update' event of
'Combo6'

Private Sub Combo6_AfterUpdate()
If IsNull(Me.TestGrade) Then
DoCmd.GoToControl ("TestGrade")
Me.TestGrade.Value = "Exec dbo.MMFindStudentGrade_sp" & Me.Combo6
End If
End Sub

The 'MMFindStudentGrade_sp' is designed to take a StudentID (Permnum)
parameter, and return the grade level of the student. The bound field
'TestGrade' is of type 'smallint'. The bound column of 'Combo6' is the
studentID. The combo box is supposed to pass the studentID value to
the procedure, and 'TestGrade' is then supposed to be populated with
the student's grade level that the procedure returns.

When I tried to test this the first time, I got an error message back
stating that the control I was trying to populate had to have the
focus. After adding the 'DoCmd.GoToContol' statement, I tested combo6
again, and got RunTime error 2113 'The value you entered is not valid
for this control'.

The following is the code for the procedure:
****************************
alter Procedure MMFindStudentGrade_sp
@Permnum varchar(12)
AS
Select Cast(Right(Grade,1)as smallint)
From Student_Data_Main
Where
Permnum=@Permnum

exec MMFindStudentGrade_sp
@Permnum = 602
**************************

I have done this type of value assignment between combo boxes, but not
from a combo box to a text box before.

How can I modify this code so that the bound text box called
'TestGrade' can be populated with the results of
'MMFindStudentGrade_sp' after Combo6 updates?

Thank you for your help!

CSDunn


Hello,

it's not so easy.

You have to use the Command-Object and retrieve the grade Value from
this object. Access has some help on the Command-Object.

HTH
Karpi
<fluctuat nec mergitur>

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.