Form Default Values

G

Guest

I have 4 fields and a button to click in order to change the values of all
four fields.

The four fields are as follows.

ser
dn
dis
psn

The button is called "NewSeries"

Here is the code that I have but for some reason it is not working.
Everything seems to be working but the ser # adding 1 to the previous default
value?


Private Sub NewSeries_Click()
Dim NewSeriesupdate As Integer
Dim NewSSequpdate As Integer

'Set default value of new series and set Play sequence of Series to 1

NewSeriesupdate = ser.DefaultValue
ser.DefaultValue = CInt(NewSerupdate + 1)
psn.DefaultValue = "1"


'To set Down to 1 for start of new series
dn.DefaultValue = "0"

'To set Distance to 1o for start of new series
dis.DefaultValue = "10"

End Sub
 
G

Guest

You should always qualify your control references with Me. I just tested
this approach, and it worked for me.

Me.ser.DefaultValue = Me.ser.DefaultValue + 1
Me.psn.DefaultValue = "1"

How about using meaningful control names? Maybe you know what they mean
now, but are you going to remember in 6 months? Anyone who comes behind you
to maintain your code will say ugly things about you when they have to figure
out what these abbreviations mean.
(just a friendly suggestion)
 
G

Guest

The code goes in the click event of the button.
In design view, select the button, select Properties, select the Events tab.
Select the Click event, then click on the small button with 3 dots.
The VBA editor will open to the event. put your code there.
 

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