vbCoders Guest



Don't have an account yet? Register
 


Forgot Password?



' FILL COMBO IN ONE FUNCTION SENDING THROUGH COMBO BOX NAME ,FILE NAME, NUMERIC FIELD , SRTING FILE

by DEEPAK (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 4th February 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)

' FILL COMBO IN ONE FUNCTION SENDING THROUGH COMBO BOX NAME ,FILE NAME, NUMERIC FIELD , SRTING FILED ' FOR FURTHER INFORMATION CONTACT

API Declarations


Dim AdoTmp As ADODB.Recordset
Public AdoConn As ADODB.Connection

Rate ' FILL COMBO IN ONE FUNCTION SENDING THROUGH COMBO BOX NAME ,FILE NAME, NUMERIC FIELD , SRTING FILE



   Set obj = New ADODB.Recordset
   obj.ActiveConnection = ADO_Conn
   obj.CursorType = adOpenKeyset
   obj.LockType = adLockOptimistic
End Sub

Public Sub Open_ADORS(obj As ADODB.Recordset, qry As String)
   With obj
      If .State = adStateOpen Then .Close
          .Open qry, , , adCmdText
    End With
End Sub

Public Sub FillCombo(Combo As ComboBox, Optional FillType As String, Optional _
   FileName As String, Optional Field1 As String, Optional Field2 As String _
   , Optional OBy As Boolean, Optional Fill_Field_Name As String, Optional FillValue As Long)
   
 
   Set_ADORS AdoTmp, AdoConn
   qry = "Select " & IIf(Field1 = "", "Code", Field1) & " as PrdCode ," _
      & IIf(Field2 = "", "Name", Field2) & " as PrdName From " & IIf(FileName = "", "AllinOne", FileName)
      If Fill_Field_Name = "" Then
         If FillType <> "" Then
            qry = qry & "  Where Type='" & UCase(FillType) & "' "
         End If
      Else
         qry = qry & "  Where " & Fill_Field_Name & "=" & FillValue
      End If
      If OBy = True Then
         qry = qry & " Order By " & IIf(Field2 = "", "Name", Field2)
      End If
   Open_ADORS AdoTmp, qry
   With Combo
      .Clear
      .Visible = False
      If AdoTmp.RecordCount < 1 Then .Visible = True: StBarMsg ClearStbar: Exit Sub
      While Not AdoTmp.EOF
         .AddItem AdoTmp!PrdName
         .ItemData(.NewIndex) = AdoTmp!Prdcode
         AdoTmp.MoveNext
      Wend
      .ListIndex = 0
      .Visible = True
      StBarMsg ClearStbar
   End With
End Sub


Download Snippet Download this snippet   Add to My Save List Add to My Saved Code

' FILL COMBO IN ONE FUNCTION SENDING THROUGH COMBO BOX NAME ,FILE NAME, NUMERIC FIELD , SRTING FILE Comments

No comments have been posted about ' FILL COMBO IN ONE FUNCTION SENDING THROUGH COMBO BOX NAME ,FILE NAME, NUMERIC FIELD , SRTING FILE. Why not be the first to post a comment about ' FILL COMBO IN ONE FUNCTION SENDING THROUGH COMBO BOX NAME ,FILE NAME, NUMERIC FIELD , SRTING FILE.

Post your comment

Subject:
Message:
0/1000 characters