matoo 28 Newbie Poster

i used do until loop

dim rsStockChk as new adodb.recordset
set rsStockChk = new adodb.recordset
rsStockChk.open "stocks", gobjconn, adopendynamic, adlockpessimistic
do untill rsStockChk.eof = true
    dim listobj as listitem
    set listobj = listview1.listitem.add(, , rsStockChk!item_code)
    listobj.subitems(1) = rsStockChk!Qty
    listobj.subitems(2) = rsStockChk!Discription
    rsStockChk.movenext
loop

adjust the code accourding to your need
matoo 28 Newbie Poster

thank you so much it worked as a charmed.

dim y as control
for each y in controls
    if typeof y is commandbutton then
        if y.name = strbuttonmame then
            y.caption = stric & " [" & rsdiscriptionfind!Qty & "]"
        end if
    end if
next
rproffitt commented: Good to read you applied the lead and fixed it. +10
matoo 28 Newbie Poster

let me put it like this i have 10 button ex.
b1
b2
b3 ..... b10
we know the names of the buttons
for example b1.caption = Coke 250ml
when i make a sale it should chk the database for stock and tell me remaing number of coke 250ml
now when the file is in loop we get the string of name but how to call the function usin value of string. that i cant figure out

matoo 28 Newbie Poster

I am writting in vb6 cause i am little use to it for other ver like .net i will have to go through studies again

matoo 28 Newbie Poster

HI everyone
i am trying to write POS and Inventory for myself in vb6. I am stuck and gone blank what to do. here is what i want to do.
search database for the stocks.
change the caption of the button ( eg caption of the botton is "COKE 250ml" and i want it to change to "COKE 250ml [30]" now [30] is the number of coke in stock.

Private Function FindButtonName()
    Dim strTest As String
    Dim strArray() As String
    Dim intCount As Integer
    Dim strButtonName As String

    Dim rsDiscriptionFind As ADODB.Recordset
    Set rsDiscriptionFind = New ADODB.Recordset
    rsDiscriptionFind.Open "Stocks", gobjConn, adOpenDynamic, adLockPessimistic

    rsDiscriptionFind.Filter = "Discription='" & strIC & "'"

    strTest = strIC
    strArray = Split(strTest, " ")

    For intCount = LBound(strArray) To UBound(strArray)
       Trim (strArray(intCount))
    Next
    If intCount = "1" Then
        strButtonName = "Cmd" & strArray(0)
    ElseIf intCount = "2" Then
        strButtonName = "Cmd" & strArray(0) & strArray(1)
    ElseIf intCount = "3" Then
        strButtonName = "Cmd" & strArray(0) & strArray(1) & strArray(2)
    ElseIf intCount = "4" Then
        strButtonName = "Cmd" & strArray(0) & strArray(1) & strArray(2) & strArray(3)
    Else
        strButtonName = "Cmd" & strArray(0) & strArray(1) & strArray(2) & strArray(3) & strArray(4)
    End If
   ' "FrmGraphicMenu.'" & strButtonName & .Caption&"'" = "test"   'this is not working
End Function

Private Sub Command7_Click()

    InitializeDB
    Dim rsStChk As New ADODB.Recordset
    Set rsStChk = New ADODB.Recordset
    rsStChk.Open "Stocks", gobjConn, adOpenDynamic, adLockPessimistic

    Dim rsSearchStock As ADODB.Recordset
    Set rsSearchStock = New ADODB.Recordset
    rsSearchStock.Open "Stocks", gobjConn, adOpenDynamic, adLockPessimistic
    Do Until rsSearchStock.EOF = True
        strIC …
matoo 28 Newbie Poster

hi there everyone this sounds sily but i am trying to make a calendar which will show attendance on the calander

what i want is to stop on the todays date txtbox

txtboxes are arreys so the name is txtDay(0), txtDay(1), txtDay(2)........... txtDay(41)

    Dim strDate As String
    Dim strStartDate As String
    Dim strDayStop As String
    strDate = Format$(Now,"D")   'if todays date is july 7th 2015
    iFIRSTDAY = 1
    sSelectedMonth = Format$(Date,"MMMM")
    sSelectedYear = Formate$(Date,"YYYY")
    iStartIndex = (Weekday(sSelectedMonth & " " & iFIRSTDAY & ", " & sSelectedYear) - 1) 'July 1 2015 - so first day to mark
    strStartDate = iStartIndex
    strStartDate = Val(strStartDate) + Val(strDate)
    strDayStop = "txtDay(" & strStartDate & ")" 'this what i want to calculate 
    strDayStop.SetFocus 'this what i want to calculate

now as you can see in the code i want to find out which txtbox to get focus accourding to todays date

Sunday Monday Tuesday Wednesday Thursday Friday Saturday
txtDay(0) txtDay(1) txtDay(2) txtDay(3) txtDay(4) txtDay(5) txtDay(6)
txtDay(7) txtDay(8) txtDay(9) txtDay(10) txtDay(11) txtDay(12) txtDay(13)
txtDay(14) txtDay(15) txtDay(16) txtDay(17) txtDay(18) txtDay(19) txtDay(20)
txtDay(21) txtDay(22) txtDay(23) txtDay(24) txtDay(25) txtDay(26) txtDay(27)
txtDay(28) txtDay(29) txtDay(30) txtDay(31) txtDay(32) txtDay(33) txtDay(34)
txtDay(35) txtDay(36) txtDay(37) txtDay(38) txtDay(39) txtDay(40) txtDay(41)

as first day of this july is wednesday so txtDay(3) is the 1st july 2015 now as of today it is 7th july 2015 it should be highlighting or setfocus to txtDay(9).

    strDayStop = "txtDay(" & strStartDate & ")" 'this what i …
matoo 28 Newbie Poster
Dim ImageFileName As String
Dim ImageFilePath As String
    ImageFileName = LblEmpCode.Caption
    ImageFileName = ImageFileName & ".jpg"
    ImageFilePath = App.Path
    ImageFilePath = ImageFilePath & "\Images\EmpPic\"
    ImageFilePath = ImageFilePath & ImageFileName
    Picture1.Picture = LoadPicture(ImageFilePath)

sorry for the truble. small mistake i figured it out as soon i got the "" removed around App.path every thing fell in place and it is running.

matoo 28 Newbie Poster

Hi there Everyone
I am writting a program POS in which i have employees database.
they get a code or we can say employee ID numbers.
100001
100002
100003
now i want to keep the recourd attached with picture ID as well
file names will be
100001.jpg
100002.jpg
100003.jpg

as i click the button to move in the records it should change the picture of the person whoes record in being displayed.
here is my code

Dim ImageFileName As String
Dim ImageFilePath As String
    ImageFileName = LblEmpCode.Caption
    ImageFileName = ImageFileName & ".jpg"
    ImageFilePath = "App"
    ImageFilePath = ImageFilePath & ".Path"
    ImageFilePath = ImageFilePath & " "
    Dim aand As String
    aand = Chr$(38)
    ImageFilePath = ImageFilePath & aand
    ImageFilePath = ImageFilePath & " "
    Dim quote As String
    quote = Chr$(34)
    ImageFilePath = ImageFilePath & quote
    ImageFilePath = ImageFilePath & "\Images\"
    ImageFilePath = ImageFilePath & "EmpPic\"
    ImageFilePath = ImageFilePath & ImageFileName
    ImageFilePath = imagefilePath & quote
    MsgBox ImageFilePath
    Picture1.Picture = LoadPicture(ImageFilePath)
    Picture1.Picture = LoadPicture(App.Path & "\Images\EmpPic\" & ImageFileName)

as my program loads employee ID is shown in LblEmpCode.Caption
in last 2 lines
Picture1.Picture = LoadPicture(ImageFilePath) -------- this gives error
where as
Picture1.Picture = LoadPicture(App.Path & "\Images\EmpPic\" & ImageFileName)
this works
i just want to know what am i doing wrong that this " Picture1.Picture = LoadPicture(ImageFilePath) " line is not working as it should
error
run-time error 75

matoo 28 Newbie Poster

thanks reverend jim my mistake thanks for pointing out i use response in what ever code i write for myself so in the description they were using reply and i used description in a mistake

Reverend Jim commented: Yeah. I've done that. +12
Nutster commented: Setting Option Explicit at the beginning of the file can help catch this kind of thing. +6
matoo 28 Newbie Poster
Dim responce As Integer 
responce = MsgBox("Are you sure you want to Logout?", vbYesNo, "Confirmation")
If reply = vbYes Then
    Unload Me
    frmAuthentication.Show
else
    exit sub
End If
matoo 28 Newbie Poster

or what you can do is use a timmer in Hidden Form when ever you lose focus of that hidden form the timmer becomes activated and then you can get back your focus on the hidden form and then you can use your key or combination of keys to unhide your form and when your form is not hidden timmer is deactivated.

matoo 28 Newbie Poster
rsCSearch.Open "SELECT * FROM Customer WHERE CName LIKE " & "'" & TxtCSearch.Text & "%'", gobjConn, adOpenStatic, adLockOptimistic

got it working % was missing thanks for your time

matoo 28 Newbie Poster

i tried the links you send but my problem is still there let me tell little more what i want and what i am getting
there is table called "Customer" fiels called "CName"
now CName is Full name
eg
Asmat
Asmat Ullah
Asmat Ullah Khan
Asmat Khan
asmat
asad
ali

now when i load the code which is

Private Sub CmdCSearch_Click()
    If TxtCSearch.Text = "" Then
        Dim info As String
        If Option1.Value = True Then
            info = "Customer ID"
        Else
            info = "Customer Name"
        End If
        MsgBox "First Enter " & info & "."
        TxtCSearch.SetFocus
    Else
        '###############################################
        Dim rsCSearch As ADODB.Recordset
        Set rsCSearch = New ADODB.Recordset
        'rsCSearch.Open "Customer", gobjConn, adOpenDynamic, adLockPessimistic
        If Option1.Value = True Then
            rsCSearch.Filter = "ID='" & TxtCSearch.Text & "'"
        Else
            'rsCSearch.Filter = "CName='" & Trim(TxtCSearch.Text) & "%'"
            'SQL = "Select * FROM Customer WHERE CName like '" & Trim(TxtCSearch.Text) & "%'"
            rsCSearch.Open "SELECT * FROM Customer WHERE CName LIKE " & "'" & TxtCSearch.Text & "'", gobjConn, adOpenStatic, adLockOptimistic
        End If
        ListView2.ListItems.Clear
        Do Until rsCSearch.EOF = True
            Dim CustomerListObj As ListItem
            Set CustomerListObj = ListView2.ListItems.add(, , rsCSearch!ID)
            CustomerListObj.SubItems(1) = rsCSearch!CName
            rsCSearch.MoveNext
        Loop
    End If
End Sub

my DB connection is connected when my main page loads
and DB info is in modules
gobjConn is the connection name

now when i enter asmat in TxtCSearch (it is the textbox) i only get two results Asmat and asmat

i want to search like if …

matoo 28 Newbie Poster
Dim gobjConn As ADODB.Connection
    Set gobjConn = New ADODB.Connection

    gobjConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
                & "Data Source=" _
                & GetAppPath _
                & "path and filename.mdb"
    Dim rAdd As ADODB.Recordset
    Set rAdd = New ADODB.Recordset
    rAdd.Open "inventory", gobjConn, adOpenDynamic, adLockPessimistic

now this is how you connect
when connected you search the item which is being sold then you filter that in the database

if new entery then use the following one line

rAdd.addnew

if only updading the existing then dont use rAdd.addnew

Dim lv2Item as string
lv2Item = item number or item code or item name what ever you want
rAdd.Filter = "ID='" & lv2Item & "'"

here ID is name of Field in the table of a database file in ms access you replace it with item code or item name table of the item being sold or what ever you what to do. now that table is parked on the item which info has to be changed
now you read the quinty and then add or subtract and put back the answer in the fiels like this

rAdd!QUANTITY = the answer
rAdd.update
rAdd.movenext

hope this helps

matoo 28 Newbie Poster

you can write a code in the lostfocus of that textbox to search that number which you entered in the database if found it give you message box telling you that the number or ID already exist and the textbox.setfocus to take you back to the same box.

matoo 28 Newbie Poster

i use my own auto number by this method
first of all load the last entery
then adding 1 in that entery
eg

Dim DBConn As ADODB.Connection
Set DBConn = New ADODB.Connection

    DBConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
                & "Data Source=" _
                & GetAppPath _
                & "anyname.mdb"
Dim rSearch As ADODB.Recordset
        Set rSearch = New ADODB.Recordset
        rSearch.Open "tablename", gobjConn, adOpenDynamic, adLockPessimistic
If rSearch.BOF = True And rSearch.EOF = True Then
        LblID.Caption = "200001"    'this is if there is no record and it is 'going to be the first entery
    Else
        rSearch.MoveLast 'here there are enteries in the database
        LblID.Caption = rSearch!ID + 1  ' eg 200001 + 1 se new Auto Number 'will be 200002
    End If
matoo 28 Newbie Poster

I am trying to write program in vb6.0, in which i am using ms access database. i want to search in a table called "customer". the Field is called "Name". in the feild i have saved full name e.g Asmat Ullah Khan, Asmat Khan, Asmat Ullah. now what i want to do is search only Asmat and it should go through whole table and display all the names in listview i.e Asmat Ullah Khan, Asmat Ullah, Asmat Khan. how can i search to get this result.Thank you