Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 417
  • Last Modified:

Spin Box Control used on Continuous Form

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;13;14;15

The form has a Record Source of a States table. Thus, when I run the Form, it displays 50 rows forthe 50 states. For each row, the user can use the Combo Box to select values in the range of 1 to 15. 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 a VBA For Dummies Programming 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 15 (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.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
   If Me.IRAFS.Value < 15 Then
      Me!IRAFS.Value = Me!IRAFS.Value + 1
   End If
End Sub
 
0
zimmer9
Asked:
zimmer9
  • 3
  • 2
1 Solution
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
One of two things:

1. Is the textbox Unbound? If so, you'll get this type of behaviour. Bind the textbox to a field (can be a dummy field in your table, if needed) and try it.

2. Are you setting focus to the record when you click the images? I don't use images like this, so I can't be sure, but make sure this isn't a focus issue by typing something into the record you're testing ... IOW, make SURE the record you're editing has the focus
0
 
zimmer9Author Commented:
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
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
1. Is the textbox Unbound? If so, you'll get this type of behaviour. Bind the textbox to a field (can be a dummy field in your table, if needed) and try it.
0
 
zimmer9Author Commented:
For the text box, if I click on the DATA tab, next to the Control Source, I selected a field from a table.
In the form, if I click on the DATA tab, next to the Record Source is the name of this same table. Thus, I would say that the text box field is bound.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Yes, it's bound ... your image control, of course, isn't and merely clicking on this may not set the focuse to your current record. Try placing a label or other control (perhaps a Frame) on top of your image control and set the properties so that you can't see it (the lable, not your spinbuttons). See if this forces your continuous form to properly set the focus ... if not, you can always rework your interface to use buttons instead of an image control ...
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now