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

Default value not showing correct value?

Status
Not open for further replies.

ProgramError

Programmer
Mar 2, 2005
1,027
GB
I have a little routine which resets all the textboxes and combo boxes on the form to their default values except for two boxes which have dates as their default values. When reset, these put either =date() or date() (which IS the default value) instead of the expected date. I could check for these particular text boxes independently but would like to use the routine as a generic routine else where in other databases. Any ideas?

Code:
Private Sub ResetInputBoxes()
Dim ctrl As Control
  For Each ctrl In Me.Form
    If ctrl.ControlType = acTextBox Or ctrl.ControlType = acComboBox Then
      ctrl = ctrl.DefaultValue
    End If
  Next
End Sub

Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
G'day Ian, how about:
Code:
Private Sub ResetInputBoxes()
Dim ctrl As Control
dim s$
  For Each ctrl In Me.Form
    If ctrl.ControlType = acTextBox Or _
           ctrl.ControlType = acComboBox Then
      s=ctrl.DefaultValue
      ctrl = Eval(Right(s, Len(s) - 1))
    End If
  Next
End Sub

Max Hugen
Australia
 
Thanks Max

I tried the eval but have errors occuring when looking at numeric textboxes, strings were fine.
Because I am checking for null in the empty textboxes by another routine, I'm also finding that this method seems to cause other problems because defaulting to null is actually entering something!

what I am trying to do is 2 fold.
1) check if any of the textboxes or comboboxes do not have any data entered into them. If this is so then highlight them. If not then copy the data into a temp order table.

2) once all the orders have been transfered to a main table and the data in the temp table cleaned up then the input textboxes need to be cleared ready for the next order list and this is where this routine comes into play.

hope that makes it a little clearer
Any ideas anyone?

Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
I'm wondering why you are entering 'orders' into a temp table first, rather than entering the data directly into the orders table?

Max Hugen
Australia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top