0% found this document useful (0 votes)
106 views

Private Sub Form - Load

This document contains code for populating dropdown lists and text boxes from database queries in VB. It includes: 1) Code to populate dropdown lists with distinct values from database queries. 2) A function to populate objects like dropdowns and text boxes from a recordset. 3) Code handling user interaction with a flexgrid control, including entering values from cells into text boxes and validating entered values.

Uploaded by

selvaa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC or read online on Scribd
0% found this document useful (0 votes)
106 views

Private Sub Form - Load

This document contains code for populating dropdown lists and text boxes from database queries in VB. It includes: 1) Code to populate dropdown lists with distinct values from database queries. 2) A function to populate objects like dropdowns and text boxes from a recordset. 3) Code handling user interaction with a flexgrid control, including entering values from cells into text boxes and validating entered values.

Uploaded by

selvaa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC or read online on Scribd
You are on page 1/ 4

Private Sub Form_Load()

Dim rs As New ADODB.Recordset


rs.Open "Select Distinct nature from AccountDueMaster where
Millname ='" & Company & "' ", con, adOpenStatic, adLockOptimistic
AddObjectValue ComboBox2, rs, "", 0
'ComboBox2.SetFocus
' rs.Open "Select Distinct Millnanme from AccountDueMaster where
Millname ='" & Company & "' ", con, adOpenStatic, adLockOptimistic
rs.Open "Select Distinct Millname from AccountDueMaster ", con,
adOpenStatic, adLockOptimistic
AddObjectValue ComboBox3, rs, "", 0

rs.Open "Select Distinct Millname from AccountDueMaster ", con,


adOpenStatic, adLockOptimistic
AddObjectValue ComboBox5, rs, "", 0

End Sub

Public Sub AddObjectValue(obj As Object, rs As


ADODB.Recordset, str As String, inta As Integer)
str = obj.Text
obj.Clear
If Not str = "" Then
obj.AddItem (str)
End If
If rs.RecordCount = 0 Then
msgstatus "No values in the table"
Else
While rs.EOF = False
obj.AddItem (rs(inta)) & ""
rs.MoveNext
Wend
End If
rs.Close
obj.Text = str
End Sub

Private Sub Text3_GotFocus()


Dim rs As New ADODB.Recordset
rs.Open "Select distinct supplierName from AccountDueMaster where
Millname ='" & Company & "' and Nature ='" & ComboBox2 & "'", con,
adOpenStatic, adLockOptimistic
list_view l2, rs, Text3, 0, 0, "", ""
l2.Visible = True
l2.SetFocus
End Sub

Private Sub MSF_EnterCell()


If MSF.Col = 1 Then
MSFDCSupEnter MSF, Combo1
ElseIf MSF.Col = 4 Then
MSFDCSupEnter MSF, Text4
Else
End If
End Sub

Public Sub MSFDCSupEnter(MSF As MSFlexGrid, txt1 As


Object)
Select Case MSF.Col
Case 1
txt1.Text = MSF.Text
txt1.Width = MSF.CellWidth
'txt1.Height = MSF.CellHeight
txt1.Left = MSF.Left + MSF.CellLeft
txt1.Top = MSF.Top + MSF.CellTop
txt1.Visible = True
txt1.SetFocus
msgstatus "Select Order No from the given list"
' Case 2
' txt1.Text = MSF.Text
' txt1.Width = MSF.CellWidth
' 'txt1.Height = MSF.CellHeight
' txt1.Left = MSF.Left + MSF.CellLeft
' txt1.Top = MSF.Top + MSF.CellTop
' txt1.Visible = True
' txt1.SetFocus
' msgstatus "select Grn No from the Given List"
' Case 3
' txt1.Text = MSF.Text
' txt1.Width = MSF.CellWidth
' 'txt1.Height = MSF.CellHeight
' txt1.Left = MSF.Left + MSF.CellLeft
' txt1.Top = MSF.Top + MSF.CellTop
' txt1.Visible = True
' txt1.SetFocus
' msgstatus "Select Yarn Name from the given list"
'
Case 4
txt1.Text = MSF.Text
txt1.Width = MSF.CellWidth
txt1.Height = MSF.CellHeight
txt1.Left = MSF.Left + MSF.CellLeft
txt1.Top = MSF.Top + MSF.CellTop
txt1.Visible = True
txt1.SetFocus
msgstatus "Enter Cheque Amount"
End Select

End Sub

Private Sub MSF_LeaveCell()


If MSF.Col = 1 Then
If Combo1.Visible Then
MSF.Text = Combo1
Combo1.Visible = False
End If
End If
' If MSF.Col = 2 Then
' If ComGRN.Visible Then
' MSF.Text = ComGRN
' ComGRN.Visible = False
' End If
' End If
' If MSF.Col = 3 Then
' If ComYarn.Visible Then
' MSF.Text = ComYarn
' ComYarn.Visible = False
' End If
' End If
If MSF.Col = 4 Then
If Text4.Visible Then
MSF.Text = Text4
If Val(MSF.Text) > Val(MSF.TextMatrix(MSF.Row, 3)) Then
MSF.Text = 0
End If
Text4.Visible = False
End If
End If
' txtChequeAmount = ""
'' Dim i As Integer
'' YarnAmount = 0
'' For i = 1 To MSF.Rows - 1
''' If strPurpose = "YarnSales" Then
'' If MSF.TextMatrix(i, 5) = "YarnSales" Then
'' YarnAmount = Val(MSF.TextMatrix(i, 4)) + Val(YarnAmount)
'' End If
'' ' Else
''
'' ' End If
'' Next i
Text1 = ""
Dim intto As Integer
For intto = 1 To MSF.Rows - 1
Text1 = Val(MSF.TextMatrix(intto, 4)) + Val(Text1)
Next intto
'End Sub

End Sub

You might also like