-
Jun 8th, 2013, 12:18 PM
#1
Thread Starter
Lively Member
code error 09 in vb 6 accounting system
hello everyone this is my first post ...
i am having an errors in the code ..:
first error is : Private Sub txt_GotFocus(Index As Integer)
SendKeys "{end}+{home}"
End Sub
second error is:
Private Sub cmdOK_Click()
If supplierflag = 1 Then
frmMMSSupplier.txt(0) = lv.ListItems(lv.SelectedItem.Index).SubItems(1)
'frmMMSSupplier.txt(0).SetFocus
Unload Me
End If
End Sub
third error is in the same form .. anyway i will post the hall script...
those errors are in the suppliers form...
Code:
Private Sub cmdedit_Click()
Call txt_unlock
cmdLookup.Enabled = True
cmdSave.Enabled = True
cmdSave.Caption = "Fresko"
cmdEdit.Enabled = False
cmdNew.Enabled = False
Command2.Enabled = True
txt(0).SetFocus
End Sub
Private Sub cmdlookup_Click()
supplierflag = 1
txt(0).SetFocus
LoadForm SupplierSearch
End Sub
Private Sub cmdnew_Click()
Call new_supplierid
Call txt_unlock
txt(0).Locked = True
cmdNew.Enabled = False
cmdEdit.Enabled = False
cmdSave.Enabled = True
Command2.Enabled = True
txt(1).SetFocus
End Sub
Private Sub cmdsave_Click()
Select Case cmdSave.Caption
Case "Ruaje"
Call dbconek
With ar
.Open "Select *From tblFurnizuesit", strConek, adOpenStatic, adLockOptimistic
.AddNew
!fur_id = txt(0)
!furnizuesi = txt(1)
!personi = txt(2)
!adresa = txt(3)
!numri = txt(4)
.Update
MsgBox "Furnizuesi u ruajt me sukses.", vbInformation, "Ruajtja!"
Call Command2_Click
.Close
End With
Case "Fresko"
Call dbconek
With ar
criteria = "Select *From tblFurnizuesit Where fur_id='" & txt(0) & "'"
.Open criteria, strConek, adOpenStatic, adLockOptimistic
!fur_id = txt(0)
!furnizuesi = txt(1)
!personi = txt(2)
!adresa = txt(3)
!numri = txt(4)
.Update
MsgBox "Furnizuesi u ruajt me sukses.", vbInformation, "Ruajtja!"
Call Command2_Click
.Close
End With
End Select
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
LoadForm frmMMSSupplier
End Sub
Private Sub new_supplierid()
On Error Resume Next
Call dbconek
Dim lastid As String
With ar
criteria = "Select *From tblFurnizuesit"
.Open criteria, strConek, adOpenStatic, adLockOptimistic
.MoveLast
lastid = Mid(!fur_id, 5, Len(!fur_id))
lastid = Val(lastid) + 1
If Len(lastid) = 1 Then
txt(0) = "FUR-" & "00" & lastid
ElseIf Len(lastid) = 2 Then
txt(0) = "FUR-" & "0" & lastid
ElseIf Len(lastid) = 3 Then
txt(0) = "FUR-" & lastid
End If
.Close
End With
End Sub
Private Sub txt_unlock()
Dim I As Integer
For I = 0 To 4
txt(I).Locked = False
Next
End Sub
Private Sub clear_txt()
Dim I As Integer
For I = 0 To 4
txt(I) = ""
Next
End Sub
Private Sub txt_KeyPress(Index As Integer, KeyAscii As Integer)
Select Case Index
Case 0
If KeyAscii = 13 Then
Call dbconek
With ar
criteria = "Select *From tblFurnizuesit Where fur_id='" & txt(0) & "'"
.Open criteria, strConek, adOpenStatic, adLockOptimistic
If .RecordCount = 1 Then
txt(1) = !furnizuesi
txt(2) = !personi
txt(3) = !adresa
txt(4) = !numri
Else
MsgBox "Furnizuesi nuk ekziston.", vbInformation, "Gabim!"
Exit Sub
End If
.Close
End With
End If
KeyAscii = Asc(UCase(Chr(KeyAscii)))
Case 1
KeyAscii = Asc(UCase(Chr(KeyAscii)))
Case 2
KeyAscii = Asc(UCase(Chr(KeyAscii)))
Case 3
KeyAscii = Asc(UCase(Chr(KeyAscii)))
Case 4
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Select
End Sub
thanks for help ... My Best Regards
-
Jun 8th, 2013, 12:26 PM
#2
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
hi i uploeaded the program with all files to mediafire .. : http://www.mediafire.com/?sl884xvp4xwdrdr
-
Jun 8th, 2013, 12:33 PM
#3
Re: code error 09 in vb 6 accounting system
Moved from the CodeBank (which is for sharing code rather than posting questions
-
Jun 8th, 2013, 01:34 PM
#4
Re: code error 09 in vb 6 accounting system
You should always state the error message rather than just the error number and you should show which line(s) the error happens on.
Much easier to help if you provide detailed info as such.
-
Jun 8th, 2013, 02:16 PM
#5
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
yes i already posted where is the error message
Private Sub txt_GotFocus(Index As Integer)
SendKeys "{end}+{home}"
End Sub
anyway i baypassed this and deleted it ... but the problem is that the hall form not saving the data... so if u can help me fix this error please i am using windows 7
thanks for replay .
-
Jun 8th, 2013, 10:07 PM
#6
Re: code error 09 in vb 6 accounting system
Originally Posted by nawar
yes i already posted where is the error message
No you posted 3 pieces of code and said you had 3 errors, the first piece is easy enough to figure out where the error happened but the second is a bit longer and the 3rd piece does not seem to be where the third error you mentioned happened but rather where something is not working the way you think it should.
In any event you did not tell us what the error message was even after I told you that you should and you did not point out the lines where the 2nd and 3rd error you mentioned were occurring. I assume they were the same message as the first since you did not say otherwise.
Always say what the error message is and always show where it occurs.
To locate your issue with the data not saving you should start by placing a break point in your save routine and then step through the code to see what code is executing when you try to save
You should also get rid of the on error resume next as that just hides errors rather than handling them
-
Jun 8th, 2013, 10:15 PM
#7
Re: code error 09 in vb 6 accounting system
The error might be due to the known issue regarding SendKeys in Windows Vista and above. See sendkeys error permission denied 70 in vb, VB Statement Against Vista and SendInput.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jun 9th, 2013, 02:12 AM
#8
Re: code error 09 in vb 6 accounting system
I don't see where an Error 9 (Subscript out of Range) will happen unless there aren't 5 TextBoxes in the Control Array (numbered from 0 to 4).
Without knowing where the error happens it's not possible to suggest anything.
However, I do notice that you're changing the Caption for cmdSave to "Fresko" when the user clicks on cmdEdit but you don't change it back to "Ruaje" when they click on cmdNew. This means that after editing a record the code will always treat a 'New' as an 'Edit' since the Select Case in cmdSave relies on the Command's Caption in order to determine what to do. Under those circumstances I'd expect an error like "No current record"
-
Jun 9th, 2013, 03:31 AM
#9
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
first of all thank you everyone for the replays ..
i already posted the pictures for the errors .. it describe the error i think
thank you so much. Greets
-
Jun 9th, 2013, 03:33 AM
#10
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
the most important the the save button don't work !! i don't know why !! and also search .. but search gives error and save dont give nothing ! it just don't save!
-
Jun 9th, 2013, 03:44 AM
#11
Re: code error 09 in vb 6 accounting system
Are you still testing for "Ruaje" and "Fresko" as Captions for cmdSave, in the Select Case statements in cmdSave ? if so then nothing will happen as the CommandButtons do not appear to have either of those Captions.
EDIT: and I see that the original error is '91' rather than '09'
Last edited by Doogle; Jun 9th, 2013 at 04:01 AM.
-
Jun 9th, 2013, 09:50 AM
#12
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
dude any one can fix this please !! i already posted the full script link to download !!
-
Jun 9th, 2013, 01:08 PM
#13
Re: code error 09 in vb 6 accounting system
Did you read Post#11? If so, what is the answer? Perhaps you should post the current code for cmdSave.
-
Jun 9th, 2013, 01:29 PM
#14
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
Mr.Doogle .. thanks for replay .. no i am not testing .. the ruaje and fresko ...
the problem is just inside the suppliers form ... i hate that form .. i can't fix it .. it's not searching and not saving the info ! i have tried already to change the hall code for the form .. but no success.. ..
can you please sir fix it for me i will be so appreciated
Best Regards .
-
Jun 9th, 2013, 10:44 PM
#15
Re: code error 09 in vb 6 accounting system
Let me get this straight: The problems are all in the Suppliers Form, yet you haven't posted the code for that form so how are we expected to fix them ?
However, in Post #1 you state "third error is in the same form .. anyway i will post the hall script... those errors are in the suppliers form..." implying that you've posted the code for that form.
That confuses me.
Please can you post all the actual code from the Suppliers Form.
-
Jun 9th, 2013, 10:47 PM
#16
Re: code error 09 in vb 6 accounting system
@nawar: I have no idea what you are talking about at this point. You say the problem is in the suppliers form which you also mentioned in the first post but you have only shown a couple of lines from that apparently and those lines have nothing to do with searching or saving anything. You said you were getting RT error 9 but your image shows a different error. You also talk about changing the hall code form but did not give any idea what you changed,
The help you will receive is limited by the info you provide and most of us are not here to "fix it for you" we are here to help you figure out how to fix it yourself so that next time you may be able to do it without needing help.
Edit: Looks like Doogle was posting while I was typing
-
Jun 9th, 2013, 10:56 PM
#17
Re: code error 09 in vb 6 accounting system
@DM: I think 'the hall script' means 'the whole script' - just a language difficulty.
-
Jun 9th, 2013, 10:57 PM
#18
Re: code error 09 in vb 6 accounting system
Originally Posted by Doogle
@DM: I think 'the hall script' means 'the whole script' - just a language difficulty.
hmm... I never would have guessed that... maybe I'll have another look at it.
-
Jun 10th, 2013, 12:38 AM
#19
Re: code error 09 in vb 6 accounting system
Well, if the code in Post #1 is the Form's code and if the picture in Post #9 is what the Form looks like, then as I said before, the Select Case statements in the code for cmdSave are looking for the Caption of cmdSave to be either "Ruaje" or "Fresko". Since the Caption seems to be "Save" then the cmdSave code will do nothing.
-
Jun 15th, 2013, 11:29 AM
#20
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
hello again thank you every one for the rplays .. and i am so sorry for my bad english ...
i already posted the link where u can download the ull script if any one can fix this ... i will appreciate that
and yes the cmdsave is doing nothing , but i want it to save the caption.
-
Jun 15th, 2013, 11:53 AM
#21
Re: code error 09 in vb 6 accounting system
I can't open .rar files. What's wrong with .zip?
-
Jun 15th, 2013, 12:17 PM
#22
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
as you wish sir ... here we go a zip file http://www.mediafire.com/?lek87g24lv26hqa
-
Jun 15th, 2013, 02:26 PM
#23
Re: code error 09 in vb 6 accounting system
I really don't know how many more times I'm going to have to say this, but look at the code for cmdSave in frmMMSSupplier
Code:
Private Sub cmdsave_Click()
Select Case cmdSave.Caption
Case "Ruaje"
Call dbconek
With ar
.Open "Select *From tblFurnizuesit", strConek, adOpenStatic, adLockOptimistic
.AddNew
!fur_id = txt(0)
!furnizuesi = txt(1)
!personi = txt(2)
!adresa = txt(3)
!numri = txt(4)
.Update
MsgBox "Furnizuesi u ruajt me sukses.", vbInformation, "Ruajtja!"
Call Command2_Click
.Close
End With
Case "Fresko"
Call dbconek
With ar
criteria = "Select *From tblFurnizuesit Where fur_id='" & txt(0) & "'"
.Open criteria, strConek, adOpenStatic, adLockOptimistic
!fur_id = txt(0)
!furnizuesi = txt(1)
!personi = txt(2)
!adresa = txt(3)
!numri = txt(4)
.Update
MsgBox "Furnizuesi u ruajt me sukses.", vbInformation, "Ruajtja!"
Call Command2_Click
.Close
End With
End Select
End Sub
Now, the Caption for cmdSave is 'Save' so what do you think will happen when you click on it ?
I'll give you a hint; the Caption is not "Ruaje" or "Fresko" which are the only 2 conditions you are testing for with the Select Case.
-
Jun 15th, 2013, 04:25 PM
#24
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
i don't get it what should i do to fix this form ...?!
i just want it to save ! when i hit save button !!
should i make it instead : case 1 and case 2 ?
-
Jun 16th, 2013, 12:14 AM
#25
Re: code error 09 in vb 6 accounting system
I take it that you're not the Author of all this code.
The cmdSave_Click event has been written to either Insert a new Supplier or Update an existing Supplier. Which operation it performs depends on the Caption of the cmdSave CommandButton, if it's "Ruaje" it will add a new Supplier, if it's "Fresko" it will update an existing Supplier.
Which of these two do you want to do ? i.e. when you click on cmdSave do you want to add a new Supplier or update an existing Supplier ?
Here's a version that will determine if the Supplier already exists and update the details and if it doesn't it will insert the details
Code:
Private Sub cmdsave_Click()
Call dbconek
With ar
.Open "Select *From tblFurnizuesit where fur_id = '" & txt(0).Text & "'", strConek, adOpenStatic, adLockOptimistic
If Not (.EOF And .BOF) Then
!fur_id = txt(0)
!furnizuesi = txt(1)
!personi = txt(2)
!adresa = txt(3)
!numri = txt(4)
.Update
MsgBox "Supplier Details for " & txt(0).Text & " have been updated", vbInformation, "Save Supplier"
Else
.AddNew
!fur_id = txt(0)
!furnizuesi = txt(1)
!personi = txt(2)
!adresa = txt(3)
!numri = txt(4)
.Update
MsgBox "Supplier Details for " & txt(0).Text & " have been inserted", vbInformation, "Save Supplier"
End If
Call Command2_Click
.Close
End With
End Sub
-
Jun 16th, 2013, 03:27 AM
#26
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
lol hi again ... i found another bug ... it's
Private Sub cmdOK_Click()
If supplierflag = 1 Then
frmMMSSupplier.txt(0) = lv.ListItems(lv.SelectedItem.Index).SubItems(1)
'frmMMSSupplier.txt(0).SetFocus
Unload Me
End If
End Sub
when i try to search :..(
-
Jun 16th, 2013, 03:30 AM
#27
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
i wanna thank everyone in this forum , specially Mr Doogle for the help i get and all the time spent answering on my questions
i really do appreciate all the help ... i am so thankfull for you Mr Doogle and everyone else who also tried to help me..
My Best Regards for you
-
Jun 16th, 2013, 03:40 AM
#28
Re: code error 09 in vb 6 accounting system
The problem with the cmdOK_Click code is that the ListView is empty and therefore no item has been selected. I suspect you've got to populate the ListView then select the item you want to search for before clicking OK.
-
Jun 16th, 2013, 04:28 AM
#29
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
yes sir thats true ... but .. i want to get the list in the listview then i want to choose one to edit but in the list view nothing appears at all..!
-
Jun 17th, 2013, 01:44 AM
#30
Re: code error 09 in vb 6 accounting system
It's just a simple matter of entering a Supplier in the textbox and pressing the enter key, that will perform the search and if found the supplier will be displayed in the ListView.
-
Jun 17th, 2013, 06:03 PM
#31
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
Originally Posted by Doogle
It's just a simple matter of entering a Supplier in the textbox and pressing the enter key, that will perform the search and if found the supplier will be displayed in the ListView.
Thank you so much i will try it my self this time .. and replay back the results
Then to help others i will re release the full program code with the source so they may learn from it as i did.. And i already made a copy of this convo to paste with the code so ur name will be included as the awesome person whom helped me finnish this program ;D thanks man ... Kisss
-
Jun 18th, 2013, 05:29 AM
#32
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
Public Sub HapKategorin()
Dim itm As ListItem
ListView1.ListItems.Clear
If Not rsKategoria.RecordCount < 1 Then rsKategoria.MoveFirst
Do Until rsKategoria.EOF
If Not IsNull(rsKategoria!kat_id) Then Set itm = ListView1.ListItems.Add(, , rsKategoria!kat_id, 1, 1)
If Not IsNull(rsKategoria!kategoria) Then itm.SubItems(1) = rsKategoria!kategoria
Here >>>> Label5.Caption = rsKategoria!kategoria <<<<< Here
rsKategoria.MoveNext
DoEvents
Loop
End Sub
error runtime 94
invalid use of null
-
Jun 19th, 2013, 06:04 PM
#33
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
Mr.Doogle i want to add to this program something like ..
for example: the prices are in euro , but the dollar changes "higher or lower" so when dollar get higher i want to change the price in euro
i have now a % percentage like if i wanna make the price hight for 2% i can do it ...
but what if i want to change all products to the new price " lower or higher" as the dollar changes...
how can i do that in this program?? i mean how and where to add this option ...
thank you.
-
Jun 20th, 2013, 01:20 AM
#34
Re: code error 09 in vb 6 accounting system
To get rid of the 'Invalid use of Null' you could change the code to something like:
Code:
Dim itm As ListItem
ListView1.ListItems.Clear
If Not (rsKategora.EOF And rsKategoria.BOF) Then
Do Until rsKategoria.EOF
If Not IsNull(rsKategoria!kat_id) Then
Set itm = ListView1.ListItems.Add(, , rsKategoria!kat_id, 1, 1)
If Not IsNull(rsKategoria!kategoria) Then
itm.SubItems(1) = rsKategoria!kategoria
Label5.Caption = rsKategoria!kategoria
End If
End If
rsKategoria.MoveNext
Loop
End If
End Sub
To change all the Prices is quite straightforward. Just put a 'Change Price' Button on the Form and a TextBox (txtDeltaPrice)
Code:
Private Sub cmdChangePrice_Click()
Dim strSQL As String
Dim curDelta As Currency
Dim rs As ADODB.Recordset
If txtDeltaPrice.Text <> "" Then
If IsNumeric(txtDeltaPrice.Text) Then
curDelta = CCur(txtDeltaPrice.Text)
Set rs = New ADODB.Recordset
strSQL = "SELECT Price FROM Table"
rs.Open db, adOpenStatic, adLockOptimistic
If Not (rs.BOF And rs.EOF) Then
Do Until rs.EOF
rs![Price] = rs![Price] + (curDelta * rs![Price] / 100)
rs.Update
rs.MoveNext
Loop
End If
Else
MsgBox "Please enter a numeric percentage value to apply to all the Prices"
End If
Else
MsgBox "Change Percentage cannot be blank"
End If
End Sub
where: 'Table' is the name of the table containing the Price, 'Price' is the column name representing the Price and 'db' is an open connection to the DataBase. Assumes that 'Price' is a Currency Type in the Table.
Entering 2.0 in txtDeltaPrice and clicking the button will uplift all the prices by 2%. Entering -2.0 in txtDelatPrice and clicking the button will reduce all the prices by 2%
Last edited by Doogle; Jun 20th, 2013 at 01:30 AM.
-
Jun 20th, 2013, 03:56 AM
#35
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
Sir the first code is awesome
Dim itm As ListItem
ListView1.ListItems.Clear
If Not (rsKategoria.EOF And rsKategoria.BOF) Then
Do Until rsKategoria.EOF
If Not IsNull(rsKategoria!kat_id) Then
Set itm = ListView1.ListItems.Add(, , rsKategoria!kat_id, 1, 1)
If Not IsNull(rsKategoria!kategoria) Then
itm.SubItems(1) = rsKategoria!kategoria
Label5.Caption = rsKategoria!kategoria
End If
End If
rsKategoria.MoveNext
Loop
End If
End Sub
but the second one is not what i want as i already have a Percentage "%" code .. but i want for example
today 1 Dollar = 5 Euro my products: coca cola 5 Euro
tomorrow 1 Dollar = 10 Euro my products: coca cola 10 Euro
now i have the % code but the one i want to change the Dollar to Euro , and by that all prices will rise or get lower prices
for example : hit here to change currency $ to € , and when i hit it a window appear and i just enter the currency i want then it will automatically calculate all the percentage it self and changes the prices.
thank you
-
Jun 20th, 2013, 04:28 AM
#36
Re: code error 09 in vb 6 accounting system
So, you're holding the Price in Euro in the Table and you want to input an exchange rate for a given currency and change all the prices to that currency.
For example, in your Table you have coca cola at 5 euros, you want to change the currency to USD and the exchange rate is 1Euro = 0.2USD so you just multiply the Euro prices by 0.2. i.e. 5Euro * 0.2 = 1USD. If the exchange rate changes to 1Euro = 0.1USD you multiply by 0.1.
I'd suggest you don't actually change the Prices in the Table itself, just perform the calculation when you display the prices on the screen.
-
Jun 20th, 2013, 04:37 AM
#37
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
yes sir thats right .. but i have a barcode .. and the prices all are in euro for example but when the $ dollar changes i should change the prices
because in many country's it changes almost everyday , and if some one sold the products when the 1 dollar = 2 euro and the dollar changes to higher or lower he will lose money ... or selling for a higher price than he should.
if you can help me do this idea i will appreciate that it will complete the program
also there is another idea, i want to discuss with you... but when we finish this step i will ask about it
-
Jun 20th, 2013, 05:10 AM
#38
Re: code error 09 in vb 6 accounting system
I'm no economist but if I'm in the US and buy some products at 10 euro I'm only interested in the exchange rate when I buy them, not when I sell them. I'll work out what it cost me in USD add my margin plus overheads and sell them at that price. If the exchange rate changes before I've sold them all, it doesn't matter until I come to purchase some more in which case I'll repeat the process.
If I'm in some sort of store which accepts multiple currency transactions, then I need to calculate, using today's exchange rate, what the selling price is for each of the currencies I accept.
Which of these are you ?
Last edited by Doogle; Jun 20th, 2013 at 05:18 AM.
-
Jun 20th, 2013, 06:43 AM
#39
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
Iam not a customer i am a retail store, thats mean i buy to sell, but i buy products with dollars and sell with euro so when i buy pen for 1$ and sell for 2 euro and the currency is 1$ = 1€ , the next day the currency is 1$ = 4€ but i still sell the pen for 2€ thats mean i lose 2€ at the same time i want to buy more products but the buy price is 1$ so the losing is more money.
So why i want with one button to change the all prices to the new currency's
-
Jun 20th, 2013, 06:44 AM
#40
Thread Starter
Lively Member
Re: code error 09 in vb 6 accounting system
With this system i just enter the today currency and it will automatically change all prices can we do that
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|