Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 23rd, 2012, 09:03 PM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Find multiple entries

I am looking for VBA code to search for multiple entries and if those multiple entries are "True" then the code will pass the Answer in a Textbox as "Hired" or "Available"
Basically I am trying to develop a little program for Hat Hire whereby if I enter the Date of when the customer wants to hire a Hat and the SKU Number of the Hat itself the code will check to see if the hat is available on that date by passing the number "1" as true or false etc and display in a Textbox as "Hired" or "Available".
I found success in doing this but i was wondering is it possible to code whereby we can check the following 4 days from the Date entered when the customer wants to hire the hat and if those days have not got the number "1" in the cells for those 5 days then the Textbox would display "Available" otherwise "Hired" etc.

I have attached a sample code etc to give you a better idea of what I have done so far. On the Form itself when you Press the HiredCheck Command Button you are checking to see if the Hat is Hired or not Hired, When you Press the SetHiredFlag Command Button you are entering a number "1" in the relevant cell corresponding to the Date & SKU Number

Hope you can help

Code:
'--------------------------------------------------------
'--------------------------------------------------------
Const DataSheet = "Data"        ' Sheet with data
Const HatDates = "B17:I17"      ' Address of dates
Const HatSKUs = "A18:A21"       ' Address of SKUs
Const FLAGGEDTEXT = "Hired"     ' Text to display
Const FLAG = 1                  ' flag
'--------------------------------------------------------
'--------------------------------------------------------
Private Sub SetFlag()    ' Set flag in table
    On Local Error GoTo errors
    With Sheets(DataSheet)
        Set DateFound = .Range(HatDates).Find(what:=TextBox1.Value)
        Set SKUFound = .Range(HatSKUs).Find(what:=TextBox2.Value)
        .Cells(SKUFound.Row, DateFound.Column) = FLAG
    End With
    Exit Sub
errors:
    MsgBox "Error: " & Err.Description
End Sub
'--------------------------------------------------------
'--------------------------------------------------------
Private Sub GetFlag()      ' display "Hired" if flagged
    On Local Error GoTo errors
    With Sheets(DataSheet)
        Me.TextBox3 = ""
        Set DateFound = .Range(HatDates).Find(what:=TextBox1.Value)
        Set SKUFound = .Range(HatSKUs).Find(what:=TextBox2.Value)
        If .Cells(SKUFound.Row, DateFound.Column) = FLAG Then Me.TextBox3 = FLAGGEDTEXT
    End With
    Exit Sub
errors:
    MsgBox "Error: " & Err.Description
End Sub
'--------------------------------------------------------
'--------------------------------------------------------
Private Sub HiredCheck_Click()
    GetFlag
End Sub
Private Sub LBDates_Click()
    Me.TextBox1 = Me.LBDates.Value
End Sub

Private Sub LBSKUs_Click()
    Me.TextBox2 = Me.LBSKUs.Value
End Sub
Private Sub SetHiredFlag_Click()
    SetFlag
End Sub
Private Sub UserForm_Initialize()
        Me.LBDates.Clear
    Me.LBSKUs.Clear
    For Each cCell In Range(HatDates).Cells
        Me.LBDates.AddItem cCell
    Next cCell
    For Each cCell In Range(HatSKUs).Cells
        Me.LBSKUs.AddItem cCell
    Next cCell
End Sub
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
find multiple values from a table field raaj Beginning PHP 0 September 17th, 2007 03:51 AM
multiple entries from one record techsp Access 2 August 2nd, 2005 10:10 AM
Find() With multiple primary keys busher ASP.NET 1.0 and 1.1 Professional 0 June 2nd, 2005 03:00 PM
Multiple formula entries as rows in a cross-tab aweller Crystal Reports 0 July 27th, 2004 04:42 AM
sql & join tables & find a field in multiple table trangd Beginning PHP 2 January 29th, 2004 07:18 PM



All times are GMT -4. The time now is 06:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.