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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spin Control On A Continuous Form

Status
Not open for further replies.
Joined
Feb 24, 2005
Messages
5
Location
US
I originally used an Access Form with a Default View of Continuous Forms. Within the design of the form, in
the Detail Section I placed a Combo Box. For the Combo Box I used a Row Source Type of a Value List and placed the accompanying values in the Row Source as 0;1;2;3;4;5;6;7;8;9;10;11;12

The form has a Record Source of a States table. Thus, when I run the Form, it displays 50 rows for the 50 states. For each row, the user can use the Combo Box to select values in the range of 1 to 12. This form works fine. However, I thought it could be improved upon. Instead of a Combo Box, I planned on switching to a Spin Box Control which I read about in an Access VBA book.

I copied the Spin Box Control picture images off the web. Then I inserted these picture images of the Spin Box Controls onto the Detail Section of my Continuous Form as a substitute for the Combo Box. I placed a text box which would receive the values 0 to 12 (to the side of these spin box controls) and assigned the text box a default value of 0. Now when I run the continous form, I once again have 50 rows for the 50 states. However, when I click on the Spin Box Control Up or Down arrows, the values ONLY change on the 1st row. In other words, no matter which row I used to click on a Spin Box Control, the ONLY accompanying text box that changes values is the top row. Do you know how I can fix this problem ?

I proceeded to add the following lines of code into the
On Click Events for the Spin Box Controls Down and Up buttons.

Private Sub SpinDownBttnI_Click()
'Decrease Skip By 1 to a minimum of 0
If Me!TextSt.Value > 0 Then
Me!TextSt.Value = Me!TextSt.Value - 1
End If
End Sub

Private Sub SpinUpBttnI_Click()
'Increase Skip By 1 to a maximum of 12
If Me!TextSt.Value < 12 Then
Me!TextSt.Value = Me!TextSt.Value + 1
End If
End Sub


 
I added a SetFocus statement to my code which I show below. It doesn't seem to make a difference in terms of the fact that the focus doesn't shift from one text box to another.

Obviously if I click inside the text box that I am trying to update and then click on the Spin Box Control next to the text box, then the correct text box is updated.

However, when I simply click on 1 Spin Box Control and then switch to another Spin Box Control without entering the corresponding text box, only the last text box that was entered will be updated. Is there a way to get around this problem ?

Private Sub SpinDownBttnI_Click()
'Decrease Skip By 1 to a minimum of 0
Me.IRAFS.SetFocus
If Me!IRAFS.Value > 0 Then
Me!IRAFS.Value = Me!IRAFS.Value - 1
End If
End Sub

Private Sub SpinUpBttnI_Click()
'Increase Skip By 1 to a maximum of 15
Me.IRAFS.SetFocus
If Me!IRAFS.Value < 15 Then
Me!IRAFS.Value = Me!IRAFS.Value + 1
End If

End Sub
 
Image controls cannot recieve focus, which is why the CurrentRecord number does not transfer when you click on an image. If you use commandbuttons, you can put the images on the buttons and then your focus will transfer properly.

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
You can also use the ActiveX version of the spin button if it is available on your system, by clicking the "More Controls" button on the Form Design toolbar, then selecting the "Microsoft Forms 2.0 SpinButton"

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top