...here is the scenario...in my inventory system i have database and it's fields are "Item Number,Description,Last Week Stocks,Deliveries,Total Stocks,Total Withdrawal and Current Stock...this is my logic if adding new stock it will add to 'Current Stock' and to 'Total Stocks' and if withdrawing stocks 'it will add to 'Total Withdrawal' and the value of the 'Last Week Stock' will update every week...can you please give me a code about my logic...
"""THE HARDEST PART OF MY PROBLEM IS EDITING THE VALUE OF THE DATABASE"""
can u please give me a code on how to edit the database value...hope you will reply on my problem because i need the finish program tomorrow...please help me... I NEED IT ASAP....
you can download my system so that you can search and study about the code that i've done...by the way the username is "admin" and the password is "admin"...tnx...I NEED THE SYSTEM SO BAD....
What databse, access, sql, MySql?
What language, VBA, VB6?
What field names etc, etc?
it is a vb6 system hope you will help me soon.. just download my program then put your code in there..then post it in this thread...tnx....i'm begging for your help...pls...help me...
You need to update the database using SQL.
Try to frame queries as per your requirement and execute them in proper event.
Don't expect someone to supply you the complete code.
Only because I'm in a good mood today!!!! ;)
I have not corrected all your code in your forms, only in form 2. This is how you would handle all the other forms. Delete all your data controls and start making use of ADO as in the code below. I gave you all the other scenarios on how to control the stock etc. When done, please mark this as solved, found at the end of this page.:)
I must just iterate again, we normally do not rewrite code for posters, you did however do a lot of coding from your side, no harm no foul.;)
Option Explicit
'##### Set a reference to MS ActiveX data objects first before ADO can be used!!
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
Dim User As String
Dim CurrentPosition As String
Dim passattemp As Integer
passattemp = 0
On Error GoTo err
If Text1.Text = vbNullString And Text2.Text = vbNullString Then 'we do not use ""
MsgBox "Data required, please enter a valid username and password!", vbCritical, "Log-in Error"
Text1.Text = vbNullString
Text2.Text = vbNullString
Text1.SetFocus
Else
Set db = New ADODB.Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\database1.mdb"
Set rs = New ADODB.Recordset
rs.Open "select * from login where username = '" & Text1 & "'", db, adOpenStatic, adLockOptimistic
'####################################################
'The following sql statements can be used in your other forms...
'Search for a specific record...
'rs.Open "SELECT * FROM INVENTORY WHERE ItemNameHere = '" & Text1.Text & "'", db, adOpenStatic, adLockOptimistic
'Search for all items say starting with W, which will show say wires, wood etc...
'rs.Open "SELECT * FROM INVENTORY WHERE ItemNameHere LIKE '" & Text1.Text & "%'", db, adOpenStatic, adLockOptimistic
'To get a value or deduct an item, the following...
'rs.Open "SELECT * FROM INVENTORY WHERE ItemNameHere = '" & Text1.Text & "'", db, adOpenStatic, adLockOptimistic
'Dim xSold As Integer
'If rs.BOF = True Or rs.EOF = True Then
'MsgBox "No items available to sell."
'Exit Sub
'Else
'xSold = rs!ItemInStockAmountNameHere
'xSold = xSold - 1
'rs!ItemInStockAmountNameHere = xSold
'rs.Update
'End If
'Use the same when you are adding stock, just mark
'xSold + 1 ...
If Not rs.EOF Then
If Text2.Text = rs!Password And Text1.Text = rs!UserName Then
MsgBox "Welcome to The System!", vbInformation, "Log-in Success"
User = Text1.Text
CurrentPosition = rs.Fields("username")
' UserType is the Table Field which has values of admin or user
'Depends on your Table Fields - change
With Form3
If rs.Fields("username").Value = "admin" Then
'all command buttons are set to Enable = True
'your codes here
.Command1.Enabled = True
.Command2.Enabled = True
.Command3.Enabled = True
.Command4.Enabled = True
.Command5.Enabled = True
Else
'all command buttons are set to Enable to False except inventory part and exit
'your codes here
.Command1.Enabled = False
.Command2.Enabled = False
.Command3.Enabled = True
.Command4.Enabled = True
.Command5.Enabled = True
End If
End With
Unload Me
Form3.Show
Else
passattemp = passattemp + 1
If passattemp = 3 Then
MsgBox "You are not an authorized user. Program will close.", vbCritical, "Log In Error"
End
'Err message if the user failed to login with a valid username and pass 3 times
Else
MsgBox "Password incorrect." & vbCrLf & " Attempt left " & passattemp & vbNullString, vbExclamation, "Log In Error"
Text1.Text = vbNullString
Text1.SetFocus
'Err message if the password entered isn't on the Password Field of the Database Table
End If
End If
Else
MsgBox "This user does not exist.", vbCritical, "Log In Error"
'Err message if the user enters a record either username or password that is not on the database
Text1.Text = vbNullString
Text2.Text = vbNullString
Text1.SetFocus
End If
End If
rs.Close
db.Close
Exit Sub
err:
MsgBox err.Description, vbCritical
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Text1_Click()
Text1.Text = vbNullString
End Sub
Private Sub Text1_GotFocus()
If Text1.Text = "Click here to enter username" Then
Text1.Text = vbNullString
End If
End Sub
please give me the code....i'm just a student and my teacher didn't teach me well about database commands and codes..please help me...if i failed to give the system tomorrow morning i will my fail subject..please help me...i need the code now...please..please...i'm begging you to help me.....
T_T
@Masterfact, pull your finger and do the code yourself. WE DO NOT DO FREE HOMEWORK HERE, POINT!
I gave you everything you needed in the code sample, now use it. If your teacher did not teach you very well as you are stating, go to his superior if he has a problem with your project not being completed. I for one WILL NOT do the rest of your homework.
Please refrain from asking another member again, it is against our posting rules!
didn't teach me well about database commands
The answer is in the code I have already supplied, just use it.
@AndreRet : you are so mean...
T_T
if asking code was against posting rules, why Mr. Abelingaw post his code on my login problem..
I hope Mr. Abelingao help me again with my problem...
If you want your assignment to be done completely then you can post your project at vworker.com. This will cost you but if you really need a complete source then try it! ;)
Post a Project for me Then I will be glad to give you a complete source ;)
I only posted that code (still basing on yours) to give you some idea regarding database connection/s.
That code was already posted by me here in the forum too (for some problems), you can at least try to fix your problem and give us some output but we don't do complete projects or those sort of things.
Regarding on your school problem, try to do ADVANCE STUDY and don't just depend on what you learn from school (been there). I think its fair to say that forums are not made for helping (ONLY) but also for STUDYING.
Just like you, I'm a student too.
Peace. :)
@AndreRet : you are so mean
. Please read our posting rules HERE. I was not mean, just upholding our rules here on Daniweb.
You have asked a question, I gave you the answer, still you want me to do your entire project, which is not allowed here.
You must keep in mind that any solution that you do get here is from members that are giving their own free time to help others out. As with many, they are also students or have employment. In my case, I am the project director for a software development company. I am probably the most active member on this forum, yet I give solutions every day. I will and can however not spend the time in doing someone elses homework for them.
If you would pass the test, do you really think it is fair to say that it is your homework. What do you think will happen when you are done studying and find employment yourself and it is required from you to do a project? It might cost you your job.
I know this sounds harsh, but that is why we have rules here at Daniweb. Yes, maybe I was a bit mean on you, being a new member and all, but I am sure that you will show much more effort in the future, not just here but in your personal studies as well.:)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.