aktharshaik 16 Posting Whiz

FlexGrid is not editable Grid. you cannot edit MSFlexgrid/MSHFlexGrid directly. u have to use another TextBox control to display covering that cell and after data is input and validated in that text box, it can be updated to the Grid.

Instead of using 2 grids, u can use a DataGrid which can Edit, Delete, Update rows dynamically without the need of any extra control.

U actually want to add a list of items with their quantities specified for the MR. Why do you want to take 1 grid, populate it with all items, then select one by one and populate them to another grid. a very tedious task.

Instead if the Grid is initially empty with only headings and an empty row say, when you enter the first column all Product Codes are dropped down and you select the required product. As soon as ur product is selected, remaining 2 columns are populated with the relevant data of the product and the cursor is moved to the quantity column. once some qty is entered you can add a new row now and move the cursor to the first column of the 2nd row... and so on...

The cursor won't move to the next row if a duplicate Item is selected/ if the qty is = zero.

Once all the items are entered, save them using the save button. For the purpose of which u may use the DataGrid. Making Editable MSFlexGrid/MSHFlexGrid requires much extra programming.

aktharshaik 16 Posting Whiz

First initialize all text boxes from txt1 to txt7 = ""
Then get the data from table using a query for sum of Stunden for different Taetigkeit and populate the textboxes.

Private Sub Combo1_Click()

    Dim rs As New ADODB.RecordSet

    On Error GoTo Combo1_Click_Error

    'This statement calls the Procedure to clear the textboxes.
    Call ClearTextBoxes

'Open the recordset where ProjektNr is 
'equal to the ComboBox Selection
'Here con is the Database Connection Object I have used.
'U have to replace with the one which u r using

    rs.Open " SELECT STUNDEN.Taetigkeit, SUM(STUNDEN.Stunden) as TotStunden FROM STUNDEN WHERE STUNDEN.ProjektNr = '" & Combo1.Text & "' GROUP BY STUNDEN.Taetigkeit ", con, adOpenKeySet, adLockReadOnly

    While Not rs.EOF()
        Select Case rs!Taetigkeit
                Case "Technische Bearbeitung"
                    txt1.Text = rs!TotStunden
                Case "CAD Erstellungen"
                    txt2.Text = rs!TotStunden
                Case "Berechnungen"
                    txt3.Text = rs!TotStunden
                Case "Besprechung"
                    txt4.Text = rs!TotStunden
                Case "Verwaltung"
                    txt5.Text = rs!TotStunden
                Case "Bauleitung"
                    txt6.Text = rs!TotStunden
                Case "Montage"
                    txt7.Text = rs!TotStunden
        End Select
        rs.MoveNext
    Wend
    If txt1.Text = "" then txt1.Text = "0"
    If txt2.Text = "" then txt2.Text = "0"
    If txt3.Text = "" then txt3.Text = "0"
    If txt4.Text = "" then txt4.Text = "0"
    If txt5.Text = "" then txt5.Text = "0"
    If txt6.Text = "" then txt6.Text = "0"
    If txt7.Text = "" then txt7.Text = "0"


Combo1_Click_Done:
    If Not rs Is Nothing Then If rs.State then rs.Close
    Set rs = Nothing
    Exit Sub

Combo1_Click_Error:
    MsgBox Err.Number & " : " & Err.Description
    Resume Combo1_Click_Done

End Sub

'This function is to clear …
aktharshaik 16 Posting Whiz

where is PO.ZIP attachment. it is not here.

aktharshaik 16 Posting Whiz

You must create a string such that it should append the values of the controls, not the control name.

INSERT INTO MyTable (Name, Age, chk_stat) VALUES ('" & txtName & "', '" & txtage & "', 0)
aktharshaik 16 Posting Whiz

u can use sequential/bubble/quick sort techniques. here is one of the logic for sorting

Dim a(5) as Integer
Dim i as Integer
Dim j as Integer

a(0) = 10
a(1) = 9
a(2) = 13
a(3) = 45
a(4) = 7

For i = 0 to 4
    For j = i + 1 to 4
        If a(i) > a(j) Then
'            swap the number in those two locations
'            For Eg: if x = 10 and y = 9 then
'                x            y
'               10           9
'             Since 10 > 9 we swap x  and  y
'                x = x + y   =>  x = 10 + 9 = 19
'                y = x - y    =>  y = 19 - 9 = 10 => y = 10
'                x = x - y    =>  x = 19 - 10 = 9 => x = 9
            a(i) = a(i) + a(j)
            a(j) = a(i) - a(j)
            a(i) = a(i) - a(j)
        End If
    Next j
Next i

'Now the array would hold the values in ascending order
'To sort in descending order just make the following change
'If a(i) < a(j) Then

hope this answers ur question. If ur need is something else other than this then plz let know.

aktharshaik 16 Posting Whiz

data reports in VB6 / Crystal Reports. any of these two would be very suitable to generate reports and print them.
If u have MSDN installed with your Visual Studio u can find most of the help of using Data Reports along with examples. else look online at Microsoft site for support.
I would recommend to give a start to Data Reports. If any problem then post ur req. here.

aktharshaik 16 Posting Whiz
aktharshaik 16 Posting Whiz

Hi! At Last came up with some solution. Try this. Checkout the Attachment.

aktharshaik 16 Posting Whiz

Yes and No values are fields that contain only one of two values (Yes/No, True/False, or On/Off). Its size is only 1 bit.
Which means it can hold only 1 bit of data. (either a 0 or 1)

when using the insert statement put 0 for No and 1 for Yes

Like

INSERT INTO MyTable (Name, Age, chk_stat) VALUES ('John', 25, 0)

where chk_stat will be stored as No. If you want it to be yes just replace 0 with 1.

aktharshaik 16 Posting Whiz

omit the keyword DISTINCT b'cos the PARTDETAIL table must have distinct values only (i think) as the item_code field is set to Primary Key.

aktharshaik 16 Posting Whiz

Also i am unable to have a picture of your form and your exact requirement.
ZIP the file and Upload

aktharshaik 16 Posting Whiz

Not much clear with ur exact requirement. If u don't mind, plz upload the DB here.

aktharshaik 16 Posting Whiz

Assuming That the First letter only in the Item_Code is an Alphabet u can write the following query to sort in the way u have asked.

rs.Open " SELECT DISTINCT ITEM_CODE, PRODUCTNAME, UNIT FROM PARTDETAIL ORDER BY UCASE(LEFT(TRIM(ITEM_CODE),1)), VAL(MID(TRIM(ITEM_CODE),2,10)) ", con, adOpenDynamic, adLockOptimistic
aktharshaik 16 Posting Whiz
Dim x As Integer
    Dim n As Integer
    Dim i As Integer
    Dim Tot As Double

    x = Val(text1.text)
    n = Val(Text2.text)
    If n <=0 Or x <1 Then
        MsgBox "Enter Proper Values"
        Exit Sub
    End If

    Tot = 0
    i = 1
    Do While i <=  n
        Tot = Tot + (x ^ i)
        i = i + 1
    Loop
    i = 0
    Do While i <=  (n + 1)
        Tot = Tot - (x ^ i)
        i = i + 1
    Loop
    MsgBox Tot
aktharshaik 16 Posting Whiz
Dim x, n, i As Integer
    Dim Tot As Double

    x = Val(Text1.Text)
    n = Val(Text2.Text)
    If n <= 1 Or x <= 0 Then
        MsgBox "Enter Proper Values", vbCritical
        Exit Sub
    End If

    Tot = 0
    i = 1
    Do While i <=  n
        Tot = Tot + (x ^ i)
        i = i + 1
    Loop
aktharshaik 16 Posting Whiz
Dim x, n, i As Integer
    Dim Tot As Double

    x = Val(Text1.Text)
    n = Val(Text2.Text)
    If n <= 1 Or x <= 0 Then
        MsgBox "Enter Proper Values", vbCritical
        Exit Sub
    End If

    Tot = 0
    i = 1
    Do While i <=  n
        Tot = Tot + (x ^ i)
        i = i + 1
    Loop
aktharshaik 16 Posting Whiz
rs.Open " SELECT DISTINCT ITEM_CODE, PRODUCTNAME, UNIT FROM PARTDETAIL ORDER BY ITEM_CODE ", con, adOpenDynamic, adLockOptimistic
aktharshaik 16 Posting Whiz
Dim Exmp As New Excel.Application
    Dim WB As Excel.Workbook
    Dim Sh As Excel.Worksheet

    Set WB = Exmp.Workbooks.Open("C:\abc.xls")
    Set Sh = WB.ActiveSheet
    Sh.PageSetup.PrintHeadings = True
    Sh.PageSetup.PrintTitleRows = "$1:$3"
    WB.Save
    Exmp.Visible = True
    Set Exmp = Nothing
aktharshaik 16 Posting Whiz

Is it in VB or MSAccess forms u r writing the code?

Please post the entire procedure which is not giving u the result.

aktharshaik 16 Posting Whiz

check out the file i have altered and uploaded it.

I have altered the Form_Load()

and

added a new procedure MSFlexGrid1_Click()

aktharshaik 16 Posting Whiz
Private Sub CommandButton1_Click()
    With ppSlide1.Shapes(3)
        'Each space is termination for a word.
        .TextFrame.TextRange.Text = "Wing PRR : Total Weight : "

        .TextFrame.TextRange.Words(1, 3).Font.Bold = msoCTrue
        .TextFrame.TextRange.Words(4, 3).Font.Bold = msoCTrue

        .TextFrame.TextRange.Words(1, 3).Font.Color = vbRed
        .TextFrame.TextRange.Words(4, 3).Font.Color = vbGreen

        .TextFrame.TextRange.Words(1, 3).Font.Size = 26
        .TextFrame.TextRange.Words(4, 3).Font.Size = 30

        .TextFrame.TextRange.Words(1, 3).Font.Name = "Tahoma"
        .TextFrame.TextRange.Words(4, 3).Font.Name = "Times New Roman"
    End With
End Sub
aktharshaik 16 Posting Whiz

when you write a union query u should see that both the queries have equal number of columns and that their datatypes are also same. If suppose one query has 6 and other query has 4 columns then query the remaining 2 columns with empty dummy data. for eg:

SELECT sNAME, sDATE, sTK, sFATHER, sAGE, sPlace FROM (SELECT Table1.name AS sNAME, Table1.date1 AS sDATE, Table1.tk AS sTK, Table1.FatherName as sFATHER, Table1.Age as sAGE, Table1.Place as sPLACE from Table1 UNION ALL SELECT Table2.add AS sNAME, Table2.date2 AS sDATE, Table2.tk2 AS sTK, '' as sFATHER, 0 as sAGE, '' as sPLACE FROM Table2) ORDER BY sNAME, sDATE

Here i assume that the Table1 having fields FatherName, Age and Place fields which are not there in Table2. hence i filled them with empty dummy fields only b'cos to match the total number of columns of both queries joined by the union query. This however being the SELECT query and is only a view, no changes are made to your actual database tables.

aktharshaik 16 Posting Whiz
Private Sub Command1_Click()
    Form2.Show vbModal
    Call cmdRefresh_Click
End Sub
aktharshaik 16 Posting Whiz

u didn't post the error msg. plz post the error msg also.

aktharshaik 16 Posting Whiz

I asked to post your code here which u have written for Addnew Button. and also the rror u get for ur show button.

just copy the vb code and paste it here in the reply to the thread.

aktharshaik 16 Posting Whiz

have u gone through the attachment given in your previous post?

http://www.daniweb.com/forums/attachment.php?attachmentid=8485&d=1228829120

aktharshaik 16 Posting Whiz

If the problem is solved please mark the thread as solved.

aktharshaik 16 Posting Whiz
rscombo.Open "select max(VAL(MID(item_code,2,10))), item_code  from production  WHERE item_code is not NULL  and  LEFT(ucase(trim(Production.ITEM_CODE)),1) = 'P' GROUP BY ITEM_CODE ORDER BY VAL(MID(item_code,2,10)) DESC"
aktharshaik 16 Posting Whiz

Try this but i am not sure. b'cos i have not tried it myself. get back if any problem.

rscombo.Open "select MAX(MID(item_code,2,10)), ITEM_CODE from production WHERE item_code is not NULL  and  LEFT(ucase(trim(Production.ITEM_CODE)),1) = 'P' GROUP BY ITEM_CODE "
aktharshaik 16 Posting Whiz

since u have both upper case and lower case alphabets in the item_code use UCase in the query for comparison.

Case Else
    rscombo.Open "select item_code from production  WHERE item_code is not NULL  and  LEFT(UCase(Trim(Production.ITEM_CODE)),1) = 'P' order by item_code ", con, adOpenDynamic, adLockOptimistic
'U need not write rscombo.MoveFirst b'cos 
'the recordset when opened will be positioned at the First Record only
'    rscombo.MoveFirst
    Do Until rscombo.EOF
        List1.AddItem rscombo.Fields("item_code")
        rscombo.MoveNext
    Loop
    Exit Sub
End Select

UCase() function converts any alphabet to its Upper Case. If the database is SQL Server use Upper()

aktharshaik 16 Posting Whiz
Case Else
    rscombo.Open "select item_code from production  WHERE item_code is not NULL  and  LEFT(Production.ITEM_CODE,1) = 'P' order by item_code ", con, adOpenDynamic, adLockOptimistic
'U need not write rscombo.MoveFirst b'cos 
'the recordset when opened will be positioned at the First Record only
'    rscombo.MoveFirst
    Do Until rscombo.EOF
        List1.AddItem rscombo.Fields("item_code")
        rscombo.MoveNext
    Loop
    Exit Sub
End Select

If any leading spaces may be in the item_code field then use the trim function.

Case Else
    rscombo.Open "select item_code from production  WHERE item_code is not NULL  and  LEFT(Trim(Production.ITEM_CODE),1) = 'P' order by item_code ", con, adOpenDynamic, adLockOptimistic
'U need not write rscombo.MoveFirst b'cos 
'the recordset when opened will be positioned at the First Record only
'    rscombo.MoveFirst
    Do Until rscombo.EOF
        List1.AddItem rscombo.Fields("item_code")
        rscombo.MoveNext
    Loop
    Exit Sub
End Select
aktharshaik 16 Posting Whiz

'In Form2

Option Explicit

Private Sub Form_Load()

    On Error GoTo Form_Load_Error

    tcpClient.RemoteHost = "localhost"
    tcpClient.RemotePort = 1001

Form_Load_Done:
    Exit Sub

Form_Load_Error:
    MsgBox Err.Number & " : " & Err.Description
    Resume Form_Load_Done

End Sub

'Connect Form 2 to Form 1
Private Sub cmdConnect_Click()

    On Error GoTo cmdConnect_Click_Error

    If tcpClient.State <> sckClosed Then tcpClient.Close
    tcpClient.Protocol = sckTCPProtocol
    tcpClient.Connect

cmdConnect_Click_Done:
    Exit Sub

cmdConnect_Click_Error:
    MsgBox Err.Number & " : " & Err.Description
    Resume cmdConnect_Click_Done

End Sub

'Sends data from form 1 to Form 1
Private Sub Command1_Click()

    On Error GoTo Command1_Click_Error

    tcpClient.SendData txtOutput.Text

Command1_Click_Done:
    Exit Sub

Command1_Click_Error:
    MsgBox Err.Number & " : " & Err.Description
    Resume Command1_Click_Done

End Sub

Private Sub timer1_timer()

    On Error GoTo timer1_timer_Error

    Label1.Caption = tcpClient.State

timer1_timer_Done:
    Exit Sub

timer1_timer_Error:
    MsgBox Err.Number & " : " & Err.Description
    Resume timer1_timer_Done

End Sub

Private Sub Command2_Click()

    On Error GoTo Command2_Click_Error

    tcpClient.SendData "SETDATA"

Command2_Click_Done:
    Exit Sub

Command2_Click_Error:
    MsgBox Err.Number & " : " & Err.Description
    Resume Command2_Click_Done

End Sub

'Listens for data from form 1 and displays it
Private Sub tcpClient_DataArrival(ByVal bytestotal As Long)

    Dim strData As String

    On Error GoTo tcpClient_DataArrival_Error

    tcpClient.GetData strData
    txtInput.Text = strData

tcpClient_DataArrival_Done:
    Exit Sub

tcpClient_DataArrival_Error:
    MsgBox Err.Number & " : " & Err.Description
    Resume tcpClient_DataArrival_Done

End Sub

'In Form1

Option Explicit

Private Sub Form_Load()

    On Error GoTo Form_Load_Error

    tcpServer.LocalPort = 1001
    tcpServer.Listen
'    frmClient.Show

Form_Load_Done:
    Exit Sub

Form_Load_Error:
    MsgBox Err.Number & " : " & Err.Description
    Resume Form_Load_Done

End Sub

Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)

    On Error GoTo tcpServer_ConnectionRequest_Error

    If tcpServer.State <> sckClosed Then …
aktharshaik 16 Posting Whiz
Dim iLoc as Integer
Dim tStr as Integer
iLoc = 0

iLoc = InStr(1, status_array(i), Format(Now(), "mm-dd-yyyy"))
tStr = ""
If  iLoc <> 0 Then
    tStr = Mid(status_array(i), iLoc, Len(status_array(i)) - (iLoc - 1))
    'tStr now holds the string extracte from Date to EndOfLine

'    If you want to omit the date then use this
'    tStr = Mid(status_array(i), iLoc+10, Len(status_array(i)) - (iLoc - 11))

End If
aktharshaik 16 Posting Whiz

if u have 2 commands and want the 2nd command to run after a certain interval of time, u can use the timer control.

During design time; set its interval property to ur required time of pause (in milliseconds), set Enable property to false

Now for the coding part, after the 1st command statement just Enable the timer. In the Timer() event of the timer, write the 2nd Command followed by Timer1.Enabled = False for the Timer control.

I assume that u have two command buttons and one timer control on your form. When the first command button is clicked it executes the statements and in the last statement of this event, the timer control is enabled. Once the timer control is enabled the counting starts and after an interval of 5000 ms the Timer() event is fired. There the call for the second command button click event is placed. After the execution of which the timer control is disabled.

If u dont disable the Timer control after the call for the Command2 click event, then Timer() event it is fired again and again for every 5000 ms.

Eg:

Private Sub Form_Load()
    Timer1.Interval = 5000 'for 5 seconds
    Timer1.Enabled = False
End Sub

Private Sub Command1_Click()
    'Write your code for the first command
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    Call Command2_Click
    Timer1.Enabled = False
End Sub

Private Sub Command2_Click()
    'Write your code for the Second Command
End Sub
aktharshaik 16 Posting Whiz
aktharshaik 16 Posting Whiz

try this link, i think there is some information which u might be interested in.
http://blogs.vbcity.com/xtab/archive/2005/11/02/5669.aspx

and also

http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=2023189&SiteID=1

aktharshaik 16 Posting Whiz

Please refer the attached document which i have extracted from Microsoft Support. Also u can view the following url if u want online.

http://support.microsoft.com/kb/191096/EN-US/

aktharshaik 16 Posting Whiz

What is the operating system in which u r running the setup? I know an issue where, if u prepare the setup in versions greater than win98 (say XP/2000) and trying to run setup in win98, u get this error. Try upgrading your win98 with any available upgrade and/or service pack.

aktharshaik 16 Posting Whiz

As far as i know you can not use formatted mixed fonts on most vb forms or controls, instead there are a few superscript characters in the arial font set that could be used.
Also i have found a link stating some free control for rich text label. here is link. check out this link, download the control, install and give a try.

http://www.zdnetasia.com/downloads/pc/swinfo/0,39043052,39001501,50001363r-39045350s,00.htm

aktharshaik 16 Posting Whiz
Vtemp = CurrentDb.OpenRecordset("SELECT MAX(CRID_INDEX.CRID_NUM) FROM CRID_INDEX")(0)

Here (0) is to return the value of the first field in the query and store it into Vtemp. If say u have more number of fields and u want to get the value of the third field in the sequence of recordset values u have to write (2) like

x = CurrentDb.OpenRecordset("SELECT sName, sLastName, sAge FROM EMPLOYEE WHERE sEmpId = 23")(2)
This will return the value of field age into variable x

aktharshaik 16 Posting Whiz

Check out the following attachment. I have modified it as far and as much as i could understand. Hope this solves ur problem.

aktharshaik 16 Posting Whiz

In programming nothing is happening unless u explicitly write code for it. U have to use a rich text box instead of a normal textbox, also u have to write the code to change any selected text to superscript/subscript/bold/any other formatting to be done. say create a button and write code in its Click() event such as when u select certain text from the rich textbox and then click that button, the text is applied the superscript format.

aktharshaik 16 Posting Whiz
Private Sub Combo1_Click()
    Set rs2 = New ADODB.Recordset
    rs2.Open "select * from Product where pcode='" & Combo1.Text & "'", cn, adOpenKeyset, adLockPessimistic
    Set MSHFlexGrid1.DataSource = rs2
    If rs2.RecordCount > 0 Then
        Text17.Text = Date
        Text4.Text = rs2!price
        If IsNull(rs2!pstock) = True Then
            Text12.Enabled = False
            MsgBox "You Cannot Buy This One" 
            Exit sub
        ElseIf VAL(rs2!pstock) <= 0 Then
            Text12.Enabled = False
            MsgBox "You Cannot Buy This One" 
            Exit Sub
        Else
            Text12.Enabled = True
        End If
    End If
End Sub
aktharshaik 16 Posting Whiz

for bold

.Shape.TextFrame.TextRange.Lines(1).Font.Bold = msoCTrue
aktharshaik 16 Posting Whiz

Also add this line for center alignment of the Title in the cell.

.Shape.TextFrame.TextRange.Lines(1).ParagraphFormat.Alignment = ppAlignCenter
aktharshaik 16 Posting Whiz

Add this line after setting the font size for underline

.Shape.TextFrame.TextRange.Lines(1).Font.Underline = msoCTrue
aktharshaik 16 Posting Whiz
Dim iVar As Integer

    For iVar = 1 To Slide1.Shapes.Count
        If Slide1.Shapes(iVar).Type = msoTable Then
            With Slide1.Shapes(iVar).Table.Cell(1, 1)
                .Shape.TextFrame.TextRange.Lines(1).Font.Name = "Verdana"
                .Shape.TextFrame.TextRange.Lines(1).Font.Size = 40
                With .Shape.TextFrame.TextRange.Lines(3).ParagraphFormat.Bullet
                    .RelativeSize = 1.25
                    .Font.Color = RGB(255, 0, 255)
                End With
                With .Shape.TextFrame.TextRange.Lines(4).ParagraphFormat.Bullet
                    .RelativeSize = 1.25
                    .Font.Color = RGB(255, 0, 255)
                End With
                With .Shape.TextFrame.TextRange.Lines(5).ParagraphFormat.Bullet
                    .RelativeSize = 1.25
                    .Font.Color = RGB(255, 0, 255)
                End With
            End With
        End If
    Next
aktharshaik 16 Posting Whiz

In the last post u can substitute any fontname and size in place of Tahoma and 20.

aktharshaik 16 Posting Whiz

If you want this to be changed programmatically then here is the code

Dim iVar As Integer

    'Here you may replace Slide1 with the name of your slide.
    For iVar = 1 To Slide1.Shapes.Count
        'Here any object which is of the type table is taken
        'An error is returned if the cell row or column do not exist.
        If Slide1.Shapes(iVar).Type = msoTable Then
            With Slide1.Shapes(iVar).Table.Cell(1, 1)
                .Shape.TextFrame.TextRange.Font.Name = "Tahoma"
                .Shape.TextFrame.TextRange.Font.Size = 20
            End With
            With Slide1.Shapes(iVar).Table.Cell(3, 1)
                With .Shape.TextFrame.TextRange.ParagraphFormat.Bullet
                    .RelativeSize = 1.25
                    .Font.Color = RGB(255, 0, 255)
                End With
            End With
            With Slide1.Shapes(iVar).Table.Cell(4, 1)
                With .Shape.TextFrame.TextRange.ParagraphFormat.Bullet
                    .RelativeSize = 1.25
                    .Font.Color = RGB(255, 0, 255)
                End With
            End With
            With Slide1.Shapes(iVar).Table.Cell(5, 1)
                With .Shape.TextFrame.TextRange.ParagraphFormat.Bullet
                    .RelativeSize = 1.25
                    .Font.Color = RGB(255, 0, 255)
                End With
            End With
        End If
    Next
aktharshaik 16 Posting Whiz

Which Table Cell. Is it in MS-Access u want?
or
Is it any cell in the FlexGrid in VB?