the program i created requires me to search from a database and display the results.for this i added a separate find for where i included an API call to display the available records as i type.
heres the code....
this is the API call..
Code:
Public Declare Function sendMessageByStrings& Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As String)
Public Const LB_SELECTSTRING = &H18C
Public gFindString As String
Public Const gDataBaseName = "C:\Documents and Settings\Apollo\My Documents\New Folder (2)\db12.mdb"
this is the code for the find form
Code:
Code:
Private Sub Form_Activate()
List1.Enabled = False
dtafind.DatabaseName = gDataBaseName
dtafind.Refresh
If (dtafind.Recordset.RecordCount > 0) Then
Screen.MousePointer = vbHourglass
dtafind.Recordset.MoveFirst
While Not dtafind.Recordset.EOF
List1.AddItem dtafind.Recordset.Fields(0) & ""
dtafind.Recordset.MoveNext
Wend
List1.Enabled = True
DoEvents
End If
lblcount = "There are " & dtafind.Recordset.RecordCount & " records"
Screen.MousePointer = vbDefault
End Sub
Public Property Let recordsource(ByVal sNewValue As String)
dtafind.recordsource = sNewValue
End Property
Private Sub Form_Unload(Cancel As Integer)
Set frmfind = Nothing
End Sub
Private Sub List1_DblClick()
gFindString = List1
Unload frmfind
End Sub
Private Sub txtfind_Change()
Dim entryNum As Long
Dim txttofind As String
txttofind = txtfind.Text
entryNum = sendMessageByStrings(List1.hwnd, LB_SELECTSTRING, 0, txttofind)
End Sub
and this is the code for linking the find form with the main program..this code is the event of clicking the "Find" button
Code:
Code:
Case cmdfind
Dim ireturn As Integer
gFindString = ""
With frmfind
.recordsource = "SELECT term FROM Table1 ORDER BY term"
.Show vbModal
End With
If (Len(gFindString) > 0) Then
With Data1.Recordset
.FindFirst "term = '" & gFindString & "' "
If (.NoMatch) Then
ireturn = MsgBox("term " & gFindString & _
" was not found.", vbCritical, "term")
Else
ireturn = MsgBox("term " & gFindString & " was retrieved.", _
vbInformation, "term")
End If
End With
End If
now the problem is..when i run the program from within vb..it runs fine..
but when i make the .exe and run it..the search part does not work.the API call and the find form responds just fine..it even says "the ' ' term was retrieved" as i had instructed i to say..but the record that is returned by the find form is not displayed in the main form
another questoin...how do i make the loacation of the database as indicated in the code independant of where the setup file install the program..i mean..here i have given the location of gDataBasename as
Public Const gDataBaseName = "C:\Documents and Settings\Apollo\My Documents\New Folder (2)\db12.mdb"
but the user may not install the program in that manner...in fact there is little chance he will.so how what code do i need to include or modify to make this program run?
i know this was a very long post..thanks for bearing with it..
waiting for ur replies..