5 Replies - 2597 Views - Last Post: 17 July 2011 - 07:29 PM

#1 devilsspawn   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-July 11

Access Database help. getting text from a combo box back into access

Posted 17 July 2011 - 03:22 PM

Hi,

i an entirely new to C# and coding all together.

i am using Visual Studio C# 2010 express.

what i am currently trying to do is take the text from a combo-box that is linked to one part of the access database and using that information as data for a table in another part of the database. i honestly have no idea on what to do, i have seach for days on google on how to interact with access from a C# windows form, but i have had no luck, i keep getting errors like "Argument 1:cannot convert from 'string' to 'int'" or i get " The best overload method match for 'WindowsFormsApplication1.Boardslogantestdataset.Test_results_Main_BoardDataTable.this[int]' has some invalid arguments"

any help would be nice.
thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Access Database help. getting text from a combo box back into access

#2 immeraufdemhund   User is offline

  • D.I.C Regular

Reputation: 79
  • View blog
  • Posts: 495
  • Joined: 29-March 10

Re: Access Database help. getting text from a combo box back into access

Posted 17 July 2011 - 04:02 PM

Access is very powerful, is their any reason why you can't stick entirely in one program? i know it is nice to program in your "native" tongue as it were, but sometimes it is better to stick with one program instead of many. I would be willing to give you a hand if you are having troubles. Unfortuntly I'm not good at all at C#, but i can tell you this. Most all textboxes in access will have a default value of string, even if it is formated otherwise. Access isn't too picky about data types and can *USUALLY* switch back and forth with no problems. Now for you though you will probably have to convert the text box value into a integer. Not sure though how you have your program interfaces with access. Can you give a little more details?
Was This Post Helpful? 0
  • +
  • -

#3 devilsspawn   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-July 11

Re: Access Database help. getting text from a combo box back into access

Posted 17 July 2011 - 04:11 PM

What im basicaly trying to do is make a front end program that interacts with a complex database, just so that data cant be changed by accident. so the only stuff i need in the program is the items that actualy need to be changed.

the combo-box where im trying to get the information from is a drop down list of items that is linked to a table in the database. so im guessing the actual information that i need is the text from the combo-box not the information coming from the database. but every time i get the text from the combo-box it just say's cannot convert string to int, which i dont know why its trying to convert it to an int in the first place, and also i have tried converting it to an int manually (with code instead of VB trying to do it) and this still doesn't work.
Was This Post Helpful? 0
  • +
  • -

#4 immeraufdemhund   User is offline

  • D.I.C Regular

Reputation: 79
  • View blog
  • Posts: 495
  • Joined: 29-March 10

Re: Access Database help. getting text from a combo box back into access

Posted 17 July 2011 - 04:56 PM

Have you tried to see what it is trying to convert to integer. What I am thinking is that most combo boxes have 2 columns for data. One of the columns though is usually hidden. Let's say you have products. (i'll use the product names from my job as example)

tblWorkOrder:
order_id
product_worked_on (a integer that is related to a product table)
...other stuff

tblProducts:
product_id (the integer that is stored in tblWorkOrder)
product_description (text that says what my products are)

so let's say in work order one I am working on a DLI-8300 (which in my tblProduct is product_id of 2) My front end will store 2 in tblWorkOrder, not DLI-8300.

and in my front end My combo box will have 2 columns. [product_id | product_description|V]

then I tell access to make the first column width of 0. Now when you click on the combo box all you will see is my product_descriptions. Now for some reason sometimes when in VBA i get the value it sometimes won't be 2 like I am expecting it will be actually DLI-8300. I suspect you are having the same problem. Try this in VBA. edit the design of your form and click on the combo box you are talking about. Go to properties and click on the event tab. Add [event proceedure] to On Change

when the VBA editor shows up do this

MsgBox Me.(name of combobox).Value

this might give you some insight as to what is going on.

Also you don't need to make a front end so that no one can edit things they shouldn't.

Make a copy of your database. Open the copy and go to Tools>startup..

Add a title to your application (change the icon if you want)

Uncheck Allow Fullmenus, allow default shortcut menues, Display Databse window, Allow built-in toolbars, allow toolbar/menu changes.

close that database then open it up.. :) now try to edit the database! (you can actually if you hold down shift and open up the database, but most people don't know that.)

so now you can just make a good front end in access, make the command buttons do what they need to do.
Was This Post Helpful? 0
  • +
  • -

#5 devilsspawn   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-July 11

Re: Access Database help. getting text from a combo box back into access

Posted 17 July 2011 - 05:14 PM

Ok. i couldnt find what you were talking about, but i tried a couple of diffrent things

first i tried
[code]
textBox1.Text = board_SNComboBox;
[code/]
and that gave me the error

Error 1 Cannot implicitly convert type 'System.Windows.Forms.ComboBox' to 'string'

so then i tried
[code]
textBox1.Text = board_SNComboBox.Text;
[code/]
and that worked and builded succesfuly and i got the text from the combo-box into the text box, but now what i need to do is to get that text back into a database table. and that's where im stuck...
Was This Post Helpful? 0
  • +
  • -

#6 immeraufdemhund   User is offline

  • D.I.C Regular

Reputation: 79
  • View blog
  • Posts: 495
  • Joined: 29-March 10

Re: Access Database help. getting text from a combo box back into access

Posted 17 July 2011 - 07:29 PM

couple of ways you can do it. If you do it from VBA you have to open a record source, and append the data into the table.

The easier way though is to make the record source for your form set to the table you want the data in. Then just bind your combobox to that particular field.

if you want, you can always shoot me an email of your database and I can give you a hand with it, or do it.. i don't care. I love working in access.

This post has been edited by immeraufdemhund: 17 July 2011 - 07:30 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1