User Setable Default Value for Field

T

tbl

On a subform, one of the fields is for recording the page
number from paper forms. I'd like the user to be able to
quickly set the default value (Integer) during data entry.

I had no trouble making Command Buttons for "Page 1", "Page
2", and "Page 3", but now the paper data is coming in with
more than 3 pages, and I'm trying to revamp the buttons to
simply have one button for "+1" and one button for "-1". But
the VBA code is giving me fits.

I've tried this:

Me.Form![sfrmIvDetail].Controls![txtPage].DefaultValue =
(Me.Form![sfrmIvDetail].Controls![txtPage].DefaultValue.Value
+ 1)

.... and many variants, but can't seem to find the right
syntax.

This is Access 2002.

Any thoughts appreciated.
 
M

Marshall Barton

tbl said:
On a subform, one of the fields is for recording the page
number from paper forms. I'd like the user to be able to
quickly set the default value (Integer) during data entry.

I had no trouble making Command Buttons for "Page 1", "Page
2", and "Page 3", but now the paper data is coming in with
more than 3 pages, and I'm trying to revamp the buttons to
simply have one button for "+1" and one button for "-1". But
the VBA code is giving me fits.

I've tried this:

Me.Form![sfrmIvDetail].Controls![txtPage].DefaultValue =
(Me.Form![sfrmIvDetail].Controls![txtPage].DefaultValue.Value
+ 1)

This is Access 2002.


Me.sfrmIvDetail.FORM.txtPage.DefaultValue = _
Val(Me.sfrmIvDetail.FORM.txtPage.DefaultValue) + 1
 
T

tbl

Me.sfrmIvDetail.FORM.txtPage.DefaultValue = _
Val(Me.sfrmIvDetail.FORM.txtPage.DefaultValue) + 1


Thanks for that, Marsh--just what I needed.

Here's what I ended up with for my two buttons:

Private Sub cmdDefPageUp_Click()

Me.frmCountDetail.Form.txtPage.DefaultValue =
Val(Me.frmCountDetail.Form.txtPage.DefaultValue) + 1
Me.[frmCountDetail].SetFocus

End Sub


Private Sub cmdDefPageDn_Click()

If Me.frmCountDetail.Form.txtPage.DefaultValue > 1 Then
Me.frmCountDetail.Form.txtPage.DefaultValue =
Val(Me.frmCountDetail.Form.txtPage.DefaultValue) - 1
Me.[frmCountDetail].SetFocus
Else: Exit Sub

End If

End Sub
 

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