Aprajita Puri
August 10th, 1999, 12:30 PM
Following is the code for usercontrol dbfind.ctl
----------------------------------------------------------------------
<vbcode>
Option Explicit
'
' Local storage
'
Private strListfield As String
Private strBoundColumn As String
Private strDBname As String
Private strRSname As String
Private StrConnect As String
Private strBoundText As Variant
'
'Event Messages
'
Public Event Selected(Selectvalue As Variant)
Public Event Cancel()
Private Sub Command1_click()
'
'User presses the button
'
Dim vartemp As Variant
'
LoadProperties
frmfind.Show vbModal
If frmfind.Closeflag = True Then
vartemp = frmfind.Selectedvalue
Unload frmfind
RaiseEvent Selected(vartemp)
Else
Unload frmfind
RaiseEvent Cancel
End If
'
End Sub
Private Sub UserControl_Initialize()
'
'Set default size
'
UserControl.Height = 315
UserControl.Width = 315
'
End Sub
Private Sub UserControl_Resize()
'
'fill out control space with button
'
With Command1
.Left = 1
.Top = 1
.Width = UserControl.Width
.Height = UserControl.Height
End With
'
End Sub
Public Property Get Databasename() As String
'
Databasename = frmfind.Data1.Databasename
'
End Property
Public Property Let Databasename(ByVal vNewValue As String)
'
strDBname = vNewValue
frmfind.Data1.Databasename = strDBname
'
End Property
Public Property Get Connect() As String
'
Connect = frmfind.Data1.Connect
'
End Property
Public Property Let Connect(ByVal vNewValue As String)
'
StrConnect = vNewValue
frmfind.Data1.Connect = StrConnect
'
End Property
Public Property Get Recordsource() As String
Recordsource = frmfind.Data1.Recordsource
'
End Property
Public Property Let Recordsource(ByVal vNewValue As String)
'
strRSname = vNewValue
frmfind.Data1.Recordsource = strRSname
'
End Property
Public Property Get Listfield() As String
'
Listfield = frmfind.DBList1.Listfield
'
End Property
Public Property Let Listfield(ByVal vNewValue As String)
'
strListfield = vNewValue
frmfind.DBList1.Listfield = strListfield
'
End Property
Public Property Get Boundcolumn() As String
'
Boundcolumn = frmfind.DBList1.Boundcolumn
'
End Property
Public Property Let Boundcolumn(ByVal vNewValue As String)
'
strBoundColumn = vNewValue
frmfind.DBList1.Boundcolumn = strBoundColumn
'
End Property
Public Property Get BoundText() As Variant
'
BoundText = frmfind.DBList1.BoundText
'
End Property
Public Sub Refresh()
'
LoadProperties
'
End Sub
Public Property Let BoundText(ByVal vNewValue As Variant)
'
frmfind.DBList1.BoundText = vNewValue
'
End Property
Public Sub Usercontrol_writeproperties(Propbag As PropertyBag)
'
'design time vars
'
With Propbag
.WriteProperty "Connect", StrConnect, ""
.WriteProperty "Databasename", strDBname, ""
.WriteProperty "Recordsource", strRSname, ""
.WriteProperty "Listfield", strListfield, ""
.WriteProperty "Boundcolumn", strBoundColumn, ""
End With
'
End Sub
Private Sub usercontrol_Readproperties(Propbag As PropertyBag)
'
'Get design time vars
'
With Propbag
strDBname = .ReadProperty("DatabaseName", " ")
StrConnect = .ReadProperty("Connect", " ")
strRSname = .ReadProperty("Recordsource", " ")
strListfield = .ReadProperty("Listfield", " ")
strBoundColumn = .ReadProperty("Boundcolumn", " ")
End With
'
End Sub
Private Sub LoadProperties()
'
'move properties into dialogue
'
frmfind.Data1.Connect = StrConnect
frmfind.Data1.Databasename = strDBname
frmfind.Data1.Recordsource = strRSname
frmfind.DBList1.Listfield = strListfield
frmfind.DBList1.Boundcolumn = strBoundColumn
frmfind.data1.refresh
frmfind.dblist1.refresh
'
End Sub
Public Sub ReturnSelected()
'
RaiseEvent Selected(frmfind.DBList1.BoundText)
'
End Sub
Public Sub ReturnCancel()
'
RaiseEvent Cancel
'
End Sub
</vbcode>
-------------------------------------------------------------------------------
in the above code(loadproperties event) if I enter
frmfind.data1.refresh
it gives me the following error while executing
"Runtime error 3170
Couldn't find installable ISAM"
where as If remove that it does not give and executes the form frmtest, which is associated with it.
also it does not populates in either cases the "the dblist" coded in dbfind.frm
Can somebody help
-------------------------------------------------------------------------------
Following is the code for dbfind.frm
<vbcode>
Private Sub Form_Load()
'
Me.Caption = "Select a Record'"
Data1.Refresh
DBList1.Refresh
'
End Sub
Private Sub DBList1_DblClick()
'
Command1_click 0
'
End Sub
Private Sub Command1_click(Index As Integer)
'
'Handle User Button Selection
'
Select Case Index
Case 0 'OK
Closeflag = True
varselectvalue = frmfind.DBList1.BoundText
Case 1 'Cancel
Closeflag = False
End Select
'
If Trim(varselectvalue) = " " Then
Closeflag = False
End If
'
Me.Hide
'
End Sub
Private Sub Form_resize()
'
With DBList1
.Left = 1
.Top = 1
.Width = Me.ScaleWidth
.Height = Me.ScaleHeight - (300 + 90 + 90)
End With
'
With Command1(0)
.Left = 120
.Top = Me.ScaleHeight - (390)
.Height = 300
.Width = Me.ScaleWidth * 0.45
.Caption = "OK"
.Default = True
End With
'
With Command1(1)
.Left = Me.ScaleWidth * 0.5
.Top = Command1(0).Top
.Height = Command1(0).Height
.Width = Command1(0).Width
.Caption = "Cancel"
.Cancel = True
End With
'
End Sub
Public Property Get Closeflag() As Variant
'
Closeflag = blncloseflag
'
End Property
Public Property Let Closeflag(ByVal vNewValue As Variant)
'
blncloseflag = vNewValue
'
End Property
Public Property Get Selectedvalue() As Variant
'
Selectedvalue = varselectvalue
'
End Property
Public Property Let Selectedvalue(ByVal vNewValue As Variant)
'
varselectvalue = vNewValue
'
End Property
</vbcode>
-----------------------------------------------------------------------------
Following is the code for frmtest form
<vbcode>
Private Sub Form_Load()
Data1.DatabaseName = "C:\Program Files\DevStudio\VB\projects\sbp.mdb"
Data1.RecordSource = "Strategy"
Stg_no.DataField = "core_stg_no"
stg_desc.DataField = "stg_desc"
stg_eff_dt.DataField = "stg_eff_date"
'
dbfind1.DatabaseName = Data1.DatabaseName
dbfind1.RecordSource = "select * from strategy order by stg_eff_dt"
dbfind1.Boundcolumn = "stg_desc"
dbfind1.Listfield = "stg_eff_date"
dbfind1.Refresh
'
End Sub
Private Sub Dbfind1_selected(selectvalue As Variant)
'
Data1.Recordset.FindFirst text2.DataField & "=" & selectvalue
'
End Sub
</vbcode>
----------------------------------------------------------------------
<vbcode>
Option Explicit
'
' Local storage
'
Private strListfield As String
Private strBoundColumn As String
Private strDBname As String
Private strRSname As String
Private StrConnect As String
Private strBoundText As Variant
'
'Event Messages
'
Public Event Selected(Selectvalue As Variant)
Public Event Cancel()
Private Sub Command1_click()
'
'User presses the button
'
Dim vartemp As Variant
'
LoadProperties
frmfind.Show vbModal
If frmfind.Closeflag = True Then
vartemp = frmfind.Selectedvalue
Unload frmfind
RaiseEvent Selected(vartemp)
Else
Unload frmfind
RaiseEvent Cancel
End If
'
End Sub
Private Sub UserControl_Initialize()
'
'Set default size
'
UserControl.Height = 315
UserControl.Width = 315
'
End Sub
Private Sub UserControl_Resize()
'
'fill out control space with button
'
With Command1
.Left = 1
.Top = 1
.Width = UserControl.Width
.Height = UserControl.Height
End With
'
End Sub
Public Property Get Databasename() As String
'
Databasename = frmfind.Data1.Databasename
'
End Property
Public Property Let Databasename(ByVal vNewValue As String)
'
strDBname = vNewValue
frmfind.Data1.Databasename = strDBname
'
End Property
Public Property Get Connect() As String
'
Connect = frmfind.Data1.Connect
'
End Property
Public Property Let Connect(ByVal vNewValue As String)
'
StrConnect = vNewValue
frmfind.Data1.Connect = StrConnect
'
End Property
Public Property Get Recordsource() As String
Recordsource = frmfind.Data1.Recordsource
'
End Property
Public Property Let Recordsource(ByVal vNewValue As String)
'
strRSname = vNewValue
frmfind.Data1.Recordsource = strRSname
'
End Property
Public Property Get Listfield() As String
'
Listfield = frmfind.DBList1.Listfield
'
End Property
Public Property Let Listfield(ByVal vNewValue As String)
'
strListfield = vNewValue
frmfind.DBList1.Listfield = strListfield
'
End Property
Public Property Get Boundcolumn() As String
'
Boundcolumn = frmfind.DBList1.Boundcolumn
'
End Property
Public Property Let Boundcolumn(ByVal vNewValue As String)
'
strBoundColumn = vNewValue
frmfind.DBList1.Boundcolumn = strBoundColumn
'
End Property
Public Property Get BoundText() As Variant
'
BoundText = frmfind.DBList1.BoundText
'
End Property
Public Sub Refresh()
'
LoadProperties
'
End Sub
Public Property Let BoundText(ByVal vNewValue As Variant)
'
frmfind.DBList1.BoundText = vNewValue
'
End Property
Public Sub Usercontrol_writeproperties(Propbag As PropertyBag)
'
'design time vars
'
With Propbag
.WriteProperty "Connect", StrConnect, ""
.WriteProperty "Databasename", strDBname, ""
.WriteProperty "Recordsource", strRSname, ""
.WriteProperty "Listfield", strListfield, ""
.WriteProperty "Boundcolumn", strBoundColumn, ""
End With
'
End Sub
Private Sub usercontrol_Readproperties(Propbag As PropertyBag)
'
'Get design time vars
'
With Propbag
strDBname = .ReadProperty("DatabaseName", " ")
StrConnect = .ReadProperty("Connect", " ")
strRSname = .ReadProperty("Recordsource", " ")
strListfield = .ReadProperty("Listfield", " ")
strBoundColumn = .ReadProperty("Boundcolumn", " ")
End With
'
End Sub
Private Sub LoadProperties()
'
'move properties into dialogue
'
frmfind.Data1.Connect = StrConnect
frmfind.Data1.Databasename = strDBname
frmfind.Data1.Recordsource = strRSname
frmfind.DBList1.Listfield = strListfield
frmfind.DBList1.Boundcolumn = strBoundColumn
frmfind.data1.refresh
frmfind.dblist1.refresh
'
End Sub
Public Sub ReturnSelected()
'
RaiseEvent Selected(frmfind.DBList1.BoundText)
'
End Sub
Public Sub ReturnCancel()
'
RaiseEvent Cancel
'
End Sub
</vbcode>
-------------------------------------------------------------------------------
in the above code(loadproperties event) if I enter
frmfind.data1.refresh
it gives me the following error while executing
"Runtime error 3170
Couldn't find installable ISAM"
where as If remove that it does not give and executes the form frmtest, which is associated with it.
also it does not populates in either cases the "the dblist" coded in dbfind.frm
Can somebody help
-------------------------------------------------------------------------------
Following is the code for dbfind.frm
<vbcode>
Private Sub Form_Load()
'
Me.Caption = "Select a Record'"
Data1.Refresh
DBList1.Refresh
'
End Sub
Private Sub DBList1_DblClick()
'
Command1_click 0
'
End Sub
Private Sub Command1_click(Index As Integer)
'
'Handle User Button Selection
'
Select Case Index
Case 0 'OK
Closeflag = True
varselectvalue = frmfind.DBList1.BoundText
Case 1 'Cancel
Closeflag = False
End Select
'
If Trim(varselectvalue) = " " Then
Closeflag = False
End If
'
Me.Hide
'
End Sub
Private Sub Form_resize()
'
With DBList1
.Left = 1
.Top = 1
.Width = Me.ScaleWidth
.Height = Me.ScaleHeight - (300 + 90 + 90)
End With
'
With Command1(0)
.Left = 120
.Top = Me.ScaleHeight - (390)
.Height = 300
.Width = Me.ScaleWidth * 0.45
.Caption = "OK"
.Default = True
End With
'
With Command1(1)
.Left = Me.ScaleWidth * 0.5
.Top = Command1(0).Top
.Height = Command1(0).Height
.Width = Command1(0).Width
.Caption = "Cancel"
.Cancel = True
End With
'
End Sub
Public Property Get Closeflag() As Variant
'
Closeflag = blncloseflag
'
End Property
Public Property Let Closeflag(ByVal vNewValue As Variant)
'
blncloseflag = vNewValue
'
End Property
Public Property Get Selectedvalue() As Variant
'
Selectedvalue = varselectvalue
'
End Property
Public Property Let Selectedvalue(ByVal vNewValue As Variant)
'
varselectvalue = vNewValue
'
End Property
</vbcode>
-----------------------------------------------------------------------------
Following is the code for frmtest form
<vbcode>
Private Sub Form_Load()
Data1.DatabaseName = "C:\Program Files\DevStudio\VB\projects\sbp.mdb"
Data1.RecordSource = "Strategy"
Stg_no.DataField = "core_stg_no"
stg_desc.DataField = "stg_desc"
stg_eff_dt.DataField = "stg_eff_date"
'
dbfind1.DatabaseName = Data1.DatabaseName
dbfind1.RecordSource = "select * from strategy order by stg_eff_dt"
dbfind1.Boundcolumn = "stg_desc"
dbfind1.Listfield = "stg_eff_date"
dbfind1.Refresh
'
End Sub
Private Sub Dbfind1_selected(selectvalue As Variant)
'
Data1.Recordset.FindFirst text2.DataField & "=" & selectvalue
'
End Sub
</vbcode>