7 Replies - 1092 Views - Last Post: 04 November 2007 - 08:25 PM Rate Topic: -----

#1 tica0419  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 08-October 07

issues with coding.. help..

Post icon  Posted 15 October 2007 - 10:30 PM

hi! im working on a program for 2 months already.. it is working fine except for 4 issues.. i have posted 3 of them here already.. ive tried researching on the web for more information but it is too difficult for me to configure the codes myself, so i would like to get some guidance from professionals like you guys..

1st issue, im having a hard time linking various hyperlinks using label to various pdf files.. ive tried various codes already including the the code below.. it worked perfectly but the problem is that my database has more than 2000 records, all with various pdf files.. all these are located in another PC.. what i wanted to happen is that instead of putting all the path name one by one for example C:\file1.pdf, C:\file2.pdf, and so on, i would like VB to search the database based on the path that is on the label caption.. here's the code that i used..

Private Sub Command1_Click()
retval = ShellExecute(Form1.hwnd, "Open", "C:\TEST.pdf", 0&, 0&, 1)
End Sub



2nd issue, case insensite database search.. Psychocoder helped me with this one but unfortunately, it didnt work in my system.. though i didnt get any errors.. anyway, my database is linked to MSFlexGrid.. im using the code below and it works fine.. it's just that i would like the system to search all those records even if it is in the lower/upper case.. here's the code..


MSFlexGrid1.FillStyle = flexFillRepeat
MSFlexGrid1.Col = 0
MSFlexGrid1.Row = 0
MSFlexGrid1.ColSel = MSFlexGrid1.Cols - 1
MSFlexGrid1.RowSel = MSFlexGrid1.Rows - 1
MSFlexGrid1.CellFontBold = False

	MSFlexGrid1.FillStyle = flexFillSingle
	
	For i = 0 To MSFlexGrid1.Cols - 1
	For j = 1 To MSFlexGrid1.Rows - 1
		
	If InStr(MSFlexGrid1.TextMatrix(j, i), TEXTSEARCH.Text) > 0 And _
	UCase("textsearch.text") = UCase(MSFlexGrid1.TextMatrix(j, i)) Then
	MSFlexGrid1.Col = i
	MSFlexGrid1.Row = j
	MSFlexGrid1.CellFontBold = True
	MSFlexGrid1.CellBackColor = &H80FFFF
	TEXTSEARCH.SetFocus
	'Else
	'MsgBox "Record not found", vbInformation + vbOKOnly, "MEMOS"
	'TEXTSEARCH.Text = ""
	'TEXTSEARCH.SetFocus
	'Exit Sub
	End If
		   
	Next j
	Next i

End Sub 


3rd issue, in one project i have several data objects.. one of the databases has 3 topics.. 2 forms in the project is linked to this database.. one form has 3 combo boxes all linked to the 3 topics.. the other form has 3 list boxes all linked to the 3 topics as well.. i tried a sample project at first using the code below, and it worked just the way i want it to.. but when i applied it to my application, i keep on getting this error "invalid use of null" for the code "combo1.additem rum1!topic" or "listtopic.additem rsMyRS!topic".. here's the code..

Dim dbMyDB As Database
Dim rsMyRS As Recordset

Private Sub Form_Load()

Set dbMyDB = OpenDatabase("F:\KAITH DBASE\FILE MAINTENANCE\TABLEACCESS.mdb")
Set rsMyRS = dbMyDB.OpenRecordset("TOPICTABLE", dbOpenDynaset)
	If Not rsMyRS.EOF Then rsMyRS.MoveFirst
	Do While rsMyRS.BOF
		LISTTOPIC.AddItem rsMyRS!TOPIC
		rsMyRS.MoveNext
	Loop

Set dbMyDB = OpenDatabase("F:\KAITH DBASE\FILE MAINTENANCE\TABLEACCESS.mdb")
Set rsMyRS = dbMyDB.OpenRecordset("SIGNTABLE", dbOpenDynaset)
	If Not rsMyRS.EOF Then rsMyRS.MoveFirst
	Do While Not rsMyRS.EOF
		LISTSIGNATORY.AddItem rsMyRS!SIGNATORY
		rsMyRS.MoveNext
	Loop

Set dbMyDB = OpenDatabase("F:\KAITH DBASE\FILE MAINTENANCE\TABLEACCESS.mdb")
Set rsMyRS = dbMyDB.OpenRecordset("FOLDERTABLE", dbOpenDynaset)
	If Not rsMyRS.EOF Then rsMyRS.MoveFirst
	Do While Not rsMyRS.EOF
		LISTFOLDER.AddItem rsMyRS!FOLDER
		rsMyRS.MoveNext
	Loop

end sub 


i used the same code for the other form with combo boxes.. i just changed rsMyRS to rum1 and dbMyDB to dum1, and listtopic to combo1, listfolder to combo2 and listsignatory to combo3..

4th issue, in another form is where the user can search the database linked to msflexgrid.. i used the same code as the one above with the case insensitive.. but what i would like to do is that all the records that matched the textsearch textbox would show in another flexgrid.. because with the code that i have, it would only highlight the records that matched and the user will have to scroll throughout the flexgrid to view the result.. i hope you guys can help me with all these issues and i hope that these codes would be helpful to others.. thanks for your time and to those who have will have or who already has shared their thoughts and ideas for my dilemma.. thanks again!

Is This A Good Question/Topic? 0
  • +

Replies To: issues with coding.. help..

#2 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: issues with coding.. help..

Posted 15 October 2007 - 10:40 PM

View Posttica0419, on 16 Oct, 2007 - 11:00 AM, said:

1st issue, im having a hard time linking various hyperlinks using label to various pdf files.. ive tried various codes already including the the code below.. it worked perfectly but the problem is that my database has more than 2000 records, all with various pdf files.. all these are located in another PC.. what i wanted to happen is that instead of putting all the path name one by one for example C:\file1.pdf, C:\file2.pdf, and so on, i would like VB to search the database based on the path that is on the label caption.. here's the code that i used..
Private Sub Command1_Click()
retval = ShellExecute(Form1.hwnd, "Open", "C:\TEST.pdf", 0&, 0&, 1)
End Sub


Could you explain what problem you have with this piece of code? Are you having a problem retrieving the path from a database or is it something else?
Was This Post Helpful? 0
  • +
  • -

#3 tica0419  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 08-October 07

Re: issues with coding.. help..

Posted 16 October 2007 - 12:12 AM

View PostLouisda16th, on 15 Oct, 2007 - 10:40 PM, said:

View Posttica0419, on 16 Oct, 2007 - 11:00 AM, said:

1st issue, im having a hard time linking various hyperlinks using label to various pdf files.. ive tried various codes already including the the code below.. it worked perfectly but the problem is that my database has more than 2000 records, all with various pdf files.. all these are located in another PC.. what i wanted to happen is that instead of putting all the path name one by one for example C:\file1.pdf, C:\file2.pdf, and so on, i would like VB to search the database based on the path that is on the label caption.. here's the code that i used..
Private Sub Command1_Click()
retval = ShellExecute(Form1.hwnd, "Open", "C:\TEST.pdf", 0&, 0&, 1)
End Sub


Could you explain what problem you have with this piece of code? Are you having a problem retrieving the path from a database or is it something else?


i was able to fix the code, so everything works fine with the 1st issue.. i created a module and then i used this code:

Private Sub Command1_Click()

hype = Text1.Text
retval = ShellExecute(Form1.hwnd, "Open", hype, 0&, 0&, 1)

End Sub


i still have 3 issues left.. :(

This post has been edited by tica0419: 16 October 2007 - 12:14 AM

Was This Post Helpful? 0
  • +
  • -

#4 tica0419  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 08-October 07

Re: issues with coding.. help..

Posted 25 October 2007 - 01:04 AM

can somebody help me please???? :(
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1619
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: issues with coding.. help..

Posted 25 October 2007 - 05:46 AM

For issue #3 there are various ways to deal with the Runtime Error'94', invalid use of null error message. First, the reason you're getting this error is because one of the values you're trying to add to your control is a null value in the database, so you need to check for it before adding it. The first is you could create your own function to check if the value is null. This function would require 2 inputs: The value being checked, and a return value if it is indeed NULL:

Function CheckNull(value As String, ReplaceValue As String) As String
	'Use IsNUll to determine if the value provided is null
	If IsNull(value) Then
		'If it is then return the ReplaceValue value
		IfNull = NullValue
	Else
		'Otherwise return the provided value
		IfNull = value
	End If
End Function

'USEAGE:
LISTTOPIC.AddItem CheckNull(rsMyRS!TOPIC,"")



Another way to combat this is to simply append an empty string to the end of the recordset value, this will provide a value other than NULL:

LISTTOPIC.AddItem rsMyRS!TOPIC & ""



FInally, theres a function, IIf available to you in VB6, with this you provide the value to check, what to return if it isnt null and what to return if it is null, like this

LISTTOPIC.AddItem IIf(rsMyRS!TOPIC,rsMyRS!TOPIC,"")



That takes care of issue #3.

For issue #2, I see your problem clearly from here, in the UCASE() for your TextBox value, you have quotes around the TextBox value UCase("textsearch.text"), that isnt going to work because then its looking for the string value textsearch.text and I truly doubt thats a value in your database. Change that line of code to

If InStr(MSFlexGrid1.TextMatrix(j, i), TEXTSEARCH.Text) > 0 And _
	UCase(textsearch.text) = UCase(MSFlexGrid1.TextMatrix(j, i)) Then



That will solve issue #2.

As for issue #4, if they're searching the values contained in the MSFlexGrid you populate in issue #2 then you're going to have to search that result set and populate a grid on another form.

Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

#6 tica0419  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 08-October 07

Re: issues with coding.. help..

Posted 30 October 2007 - 01:43 AM

thanks for your time and for your help.. i'll work on the codes by tomorrow.. thanks a lot!!!! :)
Was This Post Helpful? 0
  • +
  • -

#7 rikki_max  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 56
  • Joined: 19-April 07

Re: issues with coding.. help..

Posted 01 November 2007 - 12:16 PM

this is a simple system to fix your searching your database example

1 textbox
1 butten requid

declerations:
	Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal	bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
	Const KEYEVENTF_KEYUP = &H2
	Const VK_LWIN = &H5B

private sub button1_click
if tb1.text = "" then
msgbox("error")
else
 Call Shell("C:\pdflocation\" & textbox1.text & ".pdf")
endif


simple system to search a folder
Was This Post Helpful? 0
  • +
  • -

#8 tica0419  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 08-October 07

Re: issues with coding.. help..

Posted 04 November 2007 - 08:25 PM

thanks for the help guys..

im done with issues 1, 2, and 3.. im working on issue #4 right now and hopefully everything will work well.. thanks!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1