I'm writing a program for my job in which we are keeping track of employees usage of food at work. The form in question interacts with an access database to a binded control with labels and textboxes. This form I'm working on is the user view which doesn't allow them to input their username, I have the user name saved to a variable but it will not display when I the add a new record. I tried many things but I'm just getting frustrated.

Is there away to add data to a row that is not displayed on the screen in a textbox for the user to see? There are 3 different "cells" (textboxes) I want to be filled in by other code without the users knowledge.

I'm currently using MSAccess 2010 and Visual Studio.net 2010

Recommended Answers

All 11 Replies

anc6802,

Set the Columns Visible Property to False for the columns you do not want your users to see.

DataGridView1.Columns(colNumber).Visible = False

anc6802,

Set the Columns Visible Property to False for the columns you do not want your users to see.

DataGridView1.Columns(colNumber).Visible = False

I'm not using the table datagrid view, I dragged the individual collumns over to the form and it turned them into textboxes. For some reason it will not do anything if I try to manually add the data to the cells. By doing it this way does it somehow disable them from taking any input?

Sorry but I haven't had much use for the auto-generated controls of the data wizards and such(I KNOW THEY ARE WONDERFUL) You still should be able to hide the text boxes with their visible properties and add code to the textbox programmatically.

My Bad, got a double post.

Thanks for the help so far,i got my code to perform the calculations but for some reason when i set the result to the textbox it does not display no matter what I try.

It seems the only way I can get the textbox in the binded control to take input is to manually type it in which i do not want done.

Also when I add another record to the dataset the id for some reason comes up as -1 and after I click on save and check the database the new row is there but if i go back later on and rerun the program i get a "invalid bookmark" error and all of the cells say "#ERROR". I'm not sure what is going on.

I think I might be able to help you out but I dont understand what you are trying to do. Help me understand better.

I see you mention rows and filling them with data but you do not have a datagrid. then what do you mean by rows and filling them with data?

Why are you trying to fill in a column that users cant even see? what are you trying to do with it?

Where is the calculation done?

In order to populate binded controls, you need to fill the table with data before you can use it. have you done that?

I believe in access db, there is a data type called autonumber. If you use this datatype, the db engine automatically increases the ID by the increment you want it to. to my understanding, you can even format the ID so you have 'ABCD'0000 <== alpha numeric ID column.

The main function of the program is so that an employee will login to the program and they can do many things, but the part i'm working on isn't working right. The point of the program is to keep track of how much food an employee eats throughout the day (we do not charge employees for food they can eat as much as they want). The form is a bound control that displays all of the cells as textboxes. Each food item has its own cell which is bound to a textbox on the screen.

Basically I went to the data sources window and draged the cells from the table to an empty form which generated the textboxes and the controls.

There are 4 cells that need to be filled in that I do not want the user to see:
ID:
user_name:
business_cost:
straight_cost:

I do not want the customer to be able to enter in the id of the cell, nor do I want them to have the ability to enter in the username then they could enter in another employees username. I also do not want the employees seeing the business cost and straight cost. Also I would like for the system date and time to be added in aswell.

I perform the calculations and the data validation (check for blank textboxes, and characters) and i can get the calculations, and username but i cannot get them to automatically appear in a textbox that vb.net created but they will work in textboxes that I made generically.

I already made the tables in msaccess already and I entered in some dummy data to fill in the first row.

The idea is that the employees are the ones who are actually filling the database and when logged in as administrator all of the cells are displayed.

I already have the ID column which is the primary key set to autonumber and when i click to add a new row the id automatically displays as -1 but in the database it shows correct but when i leave the program msaccess gives me the "invalid bookmark" error and all if the data that I entered in previously is now gone.

I hope this clears up any confusion, I'm sorry about that; i've been working on this just about everyday for the past couple of weeks, even though i have all winter to get it done.

I just want to make sure i'm not trying to make vb.net do something it cannot, but I was able to make this work for the other tables and it works fine but i'm not hiding anything in those forms.

Thanks for the help in advance!

I have figured out that i had to declare another string variable, then create a new label, assign the variable to the total then assign that to the new label then assign the label to the binded control textbox vb.net created and it works.

Dim test2 As String = "Poop"
        lbltest2.Text = usrName
        test2 = lbltest2.Text
        User_nameTextBox.Text = test2

But I still get the "invalid bookmark" error when I insert data into the database in debug mode, but if I run the compiled program it will insert the data but if I close the program and re-run it, all of the data in the database that I entered in previously disappears, like I never entered it in

I'd say leave the autonumber out of the insert, but without any code it's just a wild guss.
PS: I don't understand why you have to do all this for a simple User_nameTextBox.Text = usrName . Worst case scenario use User_nameTextBox.Text = usrName.tostring .

The program got corrupted so i re-wrote the whole program and created a new database,it puts the information into the database now just fine but when I exit the program and re load it all of the information I entered in dissapears and i load the database to check it and all of the new rows say "#ERROR" and I get the 'invalid bookmark' error. I don't understand what that means? Please help

The error is "Not a valid bookmark" it appears for some reason after I insert the new rows and a exit the program and reload it it forgets about the new rows and tries to add the new rows on top of the old ones. is there away to make msaccess remember where it left off?? It doesn't make any sense that it doesn't know where it left off. I compacted/repaired the database. The primary key is not included with the insert statement and it is also set to autonumber which it is doing?

Thanks for the help in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.