473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with Two TextBox in one field and some PLEASE!!!

I have this peroblem thats really bugging me for days, please have a patience to read it and help me find the probplem because I knew I missed it and just cant tell where.
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
  1. Public Sub AddRec()
  2. Dim rsMyTable As Recordset
  3.  
  4. Set rsMyTable = New ADODB.Recordset
  5. rsMyTable.ActiveConnection = CurrentProject.Connection
  6. rsMyTable.Open "tblProductSummary", , adOpenKeyset, adLockOptimistic, adCmdTable
  7.  
  8. 'istart my adding
  9. rsMyTable.AddNew
  10. Text0.SetFocus
  11. rsMyTable.Fields("ItemID") = Text0.Text
  12. Text2.SetFocus
  13. rsMyTable.Fields("Manufacturer") = Text2.Text
  14. Text4.SetFocus
  15. rsMyTable.Fields("Manufacturer") = Text4.Text
  16.  
  17. rsMyTable.Update
  18. End Sub
My problem is that when I assign two textbox for one field, why can’t msaccess accept this two entry, I’ve read some online tutorial, and some of them really make sure that by setting focus on the textbox, will automatically add the Items in the table.the reason I made two boxes in one field is becuase I want my table to show the date and how many Items were sold on that day. Why is this happening? Why does everytime I made an entry only one textbox is beeing recognise, I really wan them both to appear on my table.I really don’t understand.

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
  1. Public Sub InsertIntoTable()
  2. Dim cnn1 As ADODB.Connection
  3. Dim rsMyTable As Recordset
  4. Dim strCmd As String
  5. Dim strCmd1 As String
  6. Dim strCmd2 As String
  7. Dim strCmd3 As String
  8. Dim strCmd4 As String
  9. Dim strCmd5 As String
  10. Dim strCmd6 As String
  11. Dim strCmd7 As String
  12.  
  13.  
  14.  
  15. Set cnn1 = New ADODB.Connection
  16. cnn1.Provider = "Microsoft.Jet.OLEDB.4.0"
  17. cnn1.Open "C:\Documents and Settings\Desktop\db1.mdb”
  18.  
  19. strCmd = "INSERT INTO tblKPIsource(WHO])VALUES('Sony')"
  20. strCmd1 = "INSERT INTO tblKPIsource([WHO])VALUES('Sanyo')"
  21. strCmd2 = "INSERT INTO tblKPIsource([WHO])VALUES('Philips')"
  22. strCmd3 = "INSERT INTO tblKPIsource([WHO])VALUES('Sony/Sanyo')"
  23. strCmd4 = "INSERT INTO tblKPIsource([WHO])VALUES('Sony/Philips')"
  24. strCmd5 = "INSERT INTO tblKPIsource([WHO])VALUES('Philips/Sanyo')"
  25. strCmd6 = "INSERT INTO tblKPIsource([WHO])VALUES('Sony/Philips/Sanyo')"
  26.  
  27. Set rsMyTable = New ADODB.Recordset
  28. rsMyTable.ActiveConnection = CurrentProject.Connection
  29. rsMyTable.Open "tblProductSummary", , adOpenKeyset, adLockOptimistic, adCmdTable
  30.  
  31.     If Me.chkA = True Then
  32.         cnn1.Execute strCmd
  33.     Else
  34.         If Me.chkB = True Then
  35.             cnn1.Execute strCmd1
  36.                 Else
  37.                     If Me.chkC = True Then
  38.                         cnn1.Execute strCmd2
  39.        End If
  40.     End If
  41. End If
  42.  
  43.     ‘combination of Items    
  44.         If Me.chkA = True  And  Me.chkB = True Then
  45.         cnn1.Execute strCmd3
  46.     Else
  47.         If Me.chkA= True and Me.chkB= True Then
  48.             cnn1.Execute strCmd4
  49.                 Else
  50.                     If Me.chkB = True And Me.chkC= True Then
  51.                         cnn1.Execute strCmd5
  52.         Else
  53.         If Me.chkB = True And Me.chkC= True And Me.chkB= True Then    
  54.         cnn1.Execute strCmd6
  55.     End If
  56.        End If
  57.     End If
  58. End If
What I want to achieve in my procedure is that after selecting only the single items, you can choose any combination. I don’t have any problem on my first set of my If-else with my checkbox, but the second half of my If-else really doesn’t participate very well. How come this happens when I put them precisely where I want them. Thinking about it shows that I really dont understand how to call check box when using it more than once.

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!!!
Mar 15 '08 #1
2 2207
Scott Price
1,384 Expert 1GB
Before we even get into your code, there are two problems I noticed right off with your table structure. First: You have two customer fields. Second: You are trying to enter double values into the manufacturer field. Both of these violate database design rules.

In the first case, you are limiting the number of customers you can associate with a particular order/manufacturer/transaction, etc... This may be fine now, while you can only think of a need to associate two, but what happens when your needs change in the future and you need to add another or three customers?

In the second case, multi-part entries into one field is just plain bad practice. It makes everything hard, as you are finding out :-)

Please take some time to read through Normalisation and Table structures and rethink the way your table is structured, leaving the coding problem alone for the moment. Then come back to the problem a little later and see what you think.

Proper design will make what you are trying to do quite simple, probably without using any code at all.

Regards,
Scott
Mar 15 '08 #2
missinglinq
3,532 Expert 2GB
Scott's advice is spot on, whereas

"I’ve read some online tutorial, and some of them really make sure that by setting focus on the textbox, will automatically add the Items in the table"

this advice is absolutely bogus! Code utilizing the .Text property does require setting focus to the control, but .Text shouldn't be used in this manner to begin with. When assigning values to a field/control you should use the .Value property, which doesn't require that focus be on the control.

rsMyTable.Fields("ItemID") = Text0.Text

should be

rsMyTable.Fields("ItemID") = Text0.Value

and .Valueis the default property of textboxes, can be shortened to rsMyTable.Fields("ItemID") = Text0

Linq ;0)>
Mar 15 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mike | last post by:
Hi All, I have been struggling with this for weeks now and I just can't get my head around it. I am trying to convert this procedure to VB.NET. In particular I am having problems with the...
1
by: jr | last post by:
Could some please direct me to the FAQ - thanks? -- --- If you need to reply personally, append "text" to the domain name in my email adr. Thanks
2
by: Leon Shaw | last post by:
What is the best way (or How) to format a form textbox field so that when the user is entering data the text don't move (like it's trying to adjust itself or something) around?
3
by: Julia | last post by:
I need help with architecture design,please: I have a server which constantly downloading messages from the internet and store them inside a data base. the server have two administrators...
2
by: donnet | last post by:
Inside my .aspx file, I have a textbox populated with data from a dataset like this: <asp:TextBox text='<%# DataBinder.Eval(Container.DataItem, "Comment")%>' id="CommentText" runat="server"...
3
by: Chrisp | last post by:
Hi! I haven't adapted to Linux yet (as much as I would like to) and I haven't installed any programmes on Linux too... I have downloaded qt-x11-opensource-src-4.2.2.tar.gz I extracted file in...
1
by: adamchiaz | last post by:
I am trying to access progressive.com and it says that javascript is disabled and i went thru everything and all the settings are correct..it is enabled and is still not recognizing...can anybody...
9
by: keydrive | last post by:
There must be a difference between a standard input field and a textbox field. I would like to use a textbox field and save the value in a hidden field for paging. This works in a default input...
2
by: ngo88 | last post by:
hi all. was just wondering if anyone would be able to normalise the following data. i have given it a go after reading through the normalisation guide (http://bytes.com/forum/thread585228.html) but...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.