I have a table named tblProuctSummary and it has the 6 fields:
ItemID - for unique key
BuyerA - for those who made the buying
BuyerB - for another buyer
Manufacturer -for identifying the source
Sold - for sold items = 1
Date - when it was sold
For problem:
1.I have to populate these fields using manual entry I used a form, so I added unbound control to my form
TextA - Entry for manufacturer
TextB - entry for manufacturer
CmdAdd - Add them to my table
Now that I have created them, I added a procedure in VB to add items, heres the code:
Expand|Select|Wrap|Line Numbers
- Public Sub AddRec()
- Dim rsMyTable As Recordset
- Set rsMyTable = New ADODB.Recordset
- rsMyTable.ActiveConnection = CurrentProject.Connection
- rsMyTable.Open "tblProductSummary", , adOpenKeyset, adLockOptimistic, adCmdTable
- 'istart my adding
- rsMyTable.AddNew
- Text0.SetFocus
- rsMyTable.Fields("ItemID") = Text0.Text
- Text2.SetFocus
- rsMyTable.Fields("Manufacturer") = Text2.Text
- Text4.SetFocus
- rsMyTable.Fields("Manufacturer") = Text4.Text
- rsMyTable.Update
- End Sub
And Now for problem 2: I need an Automatic insert Item for those Items that I have found similar and heres where the manufacturer field becomes populated, therefore I made another procedure using Insert Into in SQL, here’s the code and I added a check box for more combinations:
ChkA - for Sony
ChkB - for Sanyo
ChkC - for Philips
Expand|Select|Wrap|Line Numbers
- Public Sub InsertIntoTable()
- Dim cnn1 As ADODB.Connection
- Dim rsMyTable As Recordset
- Dim strCmd As String
- Dim strCmd1 As String
- Dim strCmd2 As String
- Dim strCmd3 As String
- Dim strCmd4 As String
- Dim strCmd5 As String
- Dim strCmd6 As String
- Dim strCmd7 As String
- Set cnn1 = New ADODB.Connection
- cnn1.Provider = "Microsoft.Jet.OLEDB.4.0"
- cnn1.Open "C:\Documents and Settings\Desktop\db1.mdb”
- strCmd = "INSERT INTO tblKPIsource(WHO])VALUES('Sony')"
- strCmd1 = "INSERT INTO tblKPIsource([WHO])VALUES('Sanyo')"
- strCmd2 = "INSERT INTO tblKPIsource([WHO])VALUES('Philips')"
- strCmd3 = "INSERT INTO tblKPIsource([WHO])VALUES('Sony/Sanyo')"
- strCmd4 = "INSERT INTO tblKPIsource([WHO])VALUES('Sony/Philips')"
- strCmd5 = "INSERT INTO tblKPIsource([WHO])VALUES('Philips/Sanyo')"
- strCmd6 = "INSERT INTO tblKPIsource([WHO])VALUES('Sony/Philips/Sanyo')"
- Set rsMyTable = New ADODB.Recordset
- rsMyTable.ActiveConnection = CurrentProject.Connection
- rsMyTable.Open "tblProductSummary", , adOpenKeyset, adLockOptimistic, adCmdTable
- If Me.chkA = True Then
- cnn1.Execute strCmd
- Else
- If Me.chkB = True Then
- cnn1.Execute strCmd1
- Else
- If Me.chkC = True Then
- cnn1.Execute strCmd2
- End If
- End If
- End If
- ‘combination of Items
- If Me.chkA = True And Me.chkB = True Then
- cnn1.Execute strCmd3
- Else
- If Me.chkA= True and Me.chkB= True Then
- cnn1.Execute strCmd4
- Else
- If Me.chkB = True And Me.chkC= True Then
- cnn1.Execute strCmd5
- Else
- If Me.chkB = True And Me.chkC= True And Me.chkB= True Then
- cnn1.Execute strCmd6
- End If
- End If
- End If
- End If
And for problem 3, I noticed that when I call Insert Into query in my code, the table puts an empty value before it adds the item in the Insert Into sql.
why does this happend, why can’t access align itself to its other members, is there a secret code that must be done to make it align, why can’t access just follow what it must do!
Now there’s no more liquid left on my brain, for I have been racking my brains for a week now, drying it all up in purpose. Please help me, I’m dragging my mouse now for I have nowhere to go. In short I’m stuck, HELP pls!!!