473,383 Members | 1,880 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,383 software developers and data experts.

Using a command button to change state of a value in a field

First, I'm an extreme novice in Access(2007-2010). I'm attempting to build a few listboxes that display items based on their state, and allows them to move from one to the next by way of command buttons. I've been trying to copy and paste snippets of other peoples example code to make this work but I'm not having a ton of success.

As it stands now I've been able to build the 3 listboxes and get them to populate correctly based upon the status of a field called "AA_Status" with 3 states: "Not Covered", "Training" and "Complete" from a table titled "STS".

I've got 3 listboxes named "ListAA_NotCovered" "ListAA_Training" and "ListAA_Complete" that I'd like the items to display between based on the corresponding states above. I also have multi-select "enhanced" enabled, which as far as I can tell requires some sort of integer based logic that I can't figure out.

I've also attached a depiction of what I'm trying to accomplish as that may make it a little easier for you to understand what I'm trying to accomplish.

If anyone can show me the necessary code to enable just one of the buttons to function I should be able to infer how the rest need to be formatted.

I truly appreciate any help, advice, or feedback you can provide. This really isn't my area of expertise at all, I'm an Air Traffic Controller by trade and I'm attempting to streamline some of our training processes through some slick MS Access forms.

-ES
Attached Files
File Type: pdf Depiction of new 623 form.pdf (103.8 KB, 176 views)
May 24 '16 #1

✓ answered by jforbes

I not so sure that ListBoxes are the best fit for what you are trying to accomplish. I think you should consider using three SubForms, where the SubForms are a DatasheetView of your Training Table. There are a couple reasons for this.

One is that it allows Access to do things the way it does them best. It doesn't have a whole lot going on when it comes to ListBoxes. It's not bad, but often a DatasheetView SubForm can perform a similar function and provide additional functionality, usually with less code. There is some pretty slick ways you can link a MainForm and SubForm together to replace the code that would need to be created for ListBoxes.

The Second is that you mention incorporating a Personnel database to populate a Trainer and Trainee. So, I'm guessing you are going to want a one to many relationship between each Trainee and every Course as well as a some kind of relationship between Trainee and Trainer and probably through the Course. This is the start of a somewhat complicated relationship that you may want to nail down before going further.

Honestly, this last part concerns me the most as you may find all the hard work you put into your database is wasted.

8 1261
NeoPa
32,556 Expert Mod 16PB
Hi. I like your approach.

What basic data are you working with?

Logic is fair enough, but without an understanding of the data in use it's without a referential basis. Three times something that isn't defined is simply something else that isn't defined.

A pretty good first stab - but we'll need that understanding in order to appreciate what we're talking about.
May 25 '16 #2
Thank you, I had hoped to explain myself better but couldn't seem to do it without writing a novel but I'll try to keep it concise.

I may have used poor terminology saying that I needed to use integer base logic. That was in reference to coding I'd seen for handling the selection of multiple items in the list box. For example:

Dim i As Integer = Listbox1.SelectedIndex

If i = -1 Then

I honestly don't know what that is intended to do, but it seemed to accomplish something similar to what I am hoping to do.

So the basic data I'm working with is a table with a field for an STS number (a discrete identifier), a corresponding title, a field to define which block of training it will be active in, and then a field that defines what state it's in when active ("not covered", "training" or "complete").

I'm using three listboxes on a form to display the STS numbers and titles in the box that corresponds to their appropriate state. I also would like buttons that would (for the user) move the STS item from one list box to the next. However, on the backend I'd like it to "move" by changing the state from one to the other. (I've already got my list boxes set up to populate based upon the appropriate block of training, and then by its state, so they are functioning how I'd like them to)

I could just use radio boxes for each STS item to display their status, but there will be approximately 40 different items and I'd like to avoid having that many items to click through, I also think it would be more aesthetically pleasing this way, particularly when I eventually print the completed forms.

Once I get this functionality accomplished I plan to pull from a personnel database to pre populate the rest of my form with trainee and trainer information, and also pre populate dates based upon a start date and defined deadlines, I'd also like to build a database that stores text from a narrative and ties it to the trainees discrete identifier. But those are all plans for down the road, I need to clear this hurdle first.

I hope I gave you enough information and a better idea of what I'm hoping to accomplish.
May 25 '16 #3
Sorry to double post, but I've been trying to read and learn some more while I wait, and I think I've made some progress. Perhaps someone can nudge me the rest of the way to where I'm trying to get with this code.
(I'm sure the error stands out like a sore thumb to you guys, but I'll describe it anyways)

On line 6 it states "Compile Error: Method or data member not found" obviously I have no idea what that means, but I'm sure one of you does.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_ToTraining_Click()
  2.  
  3.     Dim x
  4.     Dim values
  5.  
  6.     For x = 0 To list_NotCovered.length - 1
  7.         If list_NotCovered.ItemData(x).Selected Then
  8.             Update t_STS.AA_Status = "Training"
  9.         End If
  10.     Next
  11.  
  12.  
  13. End Sub
May 26 '16 #4
PhilOfWalton
1,430 Expert 1GB
It might pay you to have a look at https://bytes.com/topic/access/answe...toolbar-dialog

Phil
May 26 '16 #5
jforbes
1,107 Expert 1GB
I not so sure that ListBoxes are the best fit for what you are trying to accomplish. I think you should consider using three SubForms, where the SubForms are a DatasheetView of your Training Table. There are a couple reasons for this.

One is that it allows Access to do things the way it does them best. It doesn't have a whole lot going on when it comes to ListBoxes. It's not bad, but often a DatasheetView SubForm can perform a similar function and provide additional functionality, usually with less code. There is some pretty slick ways you can link a MainForm and SubForm together to replace the code that would need to be created for ListBoxes.

The Second is that you mention incorporating a Personnel database to populate a Trainer and Trainee. So, I'm guessing you are going to want a one to many relationship between each Trainee and every Course as well as a some kind of relationship between Trainee and Trainer and probably through the Course. This is the start of a somewhat complicated relationship that you may want to nail down before going further.

Honestly, this last part concerns me the most as you may find all the hard work you put into your database is wasted.
May 26 '16 #6
PhilofWalton, thank you so much for that link, that looks almost exactly like what I'm trying to accomplish! I'm going to sit here for an hour or two and try to digest that information to see if I can make it work out on my end.

jforbes, thank you as well for the advice and input, I think you're spot on with your concerns. As I've started developing this rudimentary form the scope quickly expanded as I started to see the potential of Access to tie together so much data. Is there any good reference that you're aware of to give me some basics of database design and normalization? I've been reading up on it at Allen Browns website, but I think another source might enhance my understanding.

Ultimately I think I'm going to press on with making this functionality work, if only as a proof of concept. Then I'll likely pause on form development while I reassess and optimize my database and table relationships.

Thank you all very much, and I'm sure I'll have more questions shortly.
May 26 '16 #7
NeoPa
32,556 Expert Mod 16PB
Hi ES.

Sorry I've not come back on this earlier. It seems like you've mainly been covered though. Shout if not.

As for your error message on line #6 of your post #4, I'd guess that list_NotCovered is a ListBox control. They don't have a property called Length. Typing in lower case is generally a good indicator of what isn't there. If Length were a valid property of that class then it would have been converted to mixed case automatically. The fact that it's still there as length indicates it's not, and that's what the compiler's complaining about.

That's why I never create variable names with all lower case letters. I'd lose a valuable source of help.
May 26 '16 #8
NeoPa
32,556 Expert Mod 16PB
Also, if you're starting out in Access, you may benefit from a few tutorials (Microsoft Access Tutorials (Strive4Peace)).

In my experience Access, and database work in general, is one of the areas where a decent basis of understanding up front is most important. Table design and structure has to be one of the first tasks, yet we tend to learn about the pitfalls only after we get past that point. My favourite one on design is by a fellow expert here at Bytes.com - Database Normalisation and Table Structures. getting that under your belt before you start can help you avoid a great deal of the problems most novice users fall over.

The best of luck anyway :-)
May 26 '16 #9

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

Similar topics

2
by: Ant | last post by:
Ok, so I have a regular input textbox on my webpage and I'm trying to work out how to make it so when the user presses a button the the textbox holds the value of a variable. I just can't work out...
9
by: rdade22 | last post by:
Hi, I'm new so try to bare with me. I'm using access 2000 and I created a database where the user is prompted to click on a command button and the info that was put on the form is sent to a table....
5
by: dgrabuloff | last post by:
i am inputting records using a form. how do i put a command button on the form that will copy the record i just input----sometimes i have the same record that needs to be put in 3 or 4 times and i...
4
by: sirimanna | last post by:
hi, Is any one can help me to open files in my computer(for an example: some word document)using command button... i want to open file's using my vb programme..but i can't do it...can any one...
4
beacon
by: beacon | last post by:
Hi everybody, I have a main form, frmDeficiency, that has a tab control, deficiencyTabControl, that has a subform, fsubEpisodeDetail, on page 2 of the tab control. I also have a command button...
1
by: marvinisla | last post by:
i am complete newbie in ms access 2007. I want to ask how to save unbound textbox value in a table using a command button? and also how to put a clock in a form. tried all the tutorial from the...
1
by: Palaniappan | last post by:
how to add an item into the textbox by using command button in ms access in the form from the table?
2
by: aanand1 | last post by:
Hi, I am unable to delete a selected record on listbox using command button. I am new to Access and have made VB code using internet help. Here is my code. Private Sub...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?

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.