Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I just wanted to say that you guys RULE, a million thank you's to whoever created, and/or manages this site. KEEP UP THE GOOD WORK..."

Geography

Where in the world do Tek-Tips members come from?
RasSpekopite (Programmer)
11 Jul 12 6:44
Hi all,
joined yesterday. Great forums here.
Here is my problem. I am designing a small app to track Meter boxes issued to a group of contractors.

I have a from "frmUpdateMeterBoxDetails" with 30 textboxes "txtBoxNo1 ... txtBoxNo30". I have so far succeeded in coming up with the code to validate whether a Meter Box has already been issued.

My problem is that I have failed to come up with a way of saving only those boxes that have not been issued and at the same time highlighting those that have already been issued.

Here is my code:
Private Sub cmdSave_Click()
Dim rs As DAO.Recordset
Dim i As Integer
Dim NoOfBoxes As Integer
Dim MeterBoxNo As String

On Error GoTo HandleError

NoOfBoxes = Me.txtNoOfBoxes
MeterBoxNo = "txtBoxNo"

Set rs = CurrentDb.OpenRecordset("tblMeterBoxNos")

For i = 1 To NoOfBoxes
With rs
If DCount("BoxNo", "tblMeterBoxNos", "BoxNo ='" & _
Me.Controls(MeterBoxNo & i).Value & "'") > 0 Then
Me.Controls(MeterBoxNo & i).ForeColor = vbRed
MsgBox "The meter box(es) in RED have already been isued." & _
" Please enter correct meter box No(s) or delete to proceed.", _
vbOKOnly, "Duplicate Meter Box No(s)!"
End If
End With
Next i

rs.Close
Set rs = Nothing

ExitHere:
Exit Sub

HandleError:
MsgBox err.Description
Resume ExitHere

End Sub

Any assistance will be greatly appreciated. I am confident that this is the coolest forum.

JBG&P!!!
RasSpekopite

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close