Help with VB for MS Access...

Live forum: http://forum.freeipodguide.com/viewtopic.php?t=49186

jadem

30-11-2006 12:31:32

Here's the thing...I created an Access (gag) DB for my workgroup to use to keep track of projects. I used Access because it has a nice GUI interface and we won't be placing it on the web anywhere. I work with people who are not technically inclined.

Anyway, here's what I'm trying to do.

I want to create a submit button on a form that takes you to the next record but also saves the information on the previous (continue reading as to why the basic record navigation doesn't work). The issue comes up with a checkbox I placed on the form to mark the project complete or not. When it is checked, all the boxes are enabled. But, it applies to all the records. Is there a way to code a submit button so only the record where you checked the box is disabled? Right now they all are when I use the available record navigation .

I know VB is simple, but I haven't coded in about 3 years and I'm not finding exactly what I'm looking for.

Help please?

dmorris68

30-11-2006 12:49:59

"Gag" is right. Access + VB. Yech.

Anywho, this should be trivial. The most obvious solution (if I understand your situation correctly) is to add a boolean column to the database table for each project record. Bind the checkbox to that column, and use an event to enable/disable the appropriate controls as each record is loaded, based on the setting of that column.

It's been ages (thankfully) since I had to code in VB, so I don't remember the exact name of the event. I think it was something like "OnNextRecord" or something like that.

jadem

30-11-2006 13:23:28

[quote4c30afb441="dmorris68"]"Gag" is right. Access + VB. Yech.

Anywho, this should be trivial. The most obvious solution (if I understand your situation correctly) is to add a boolean column to the database table for each project record. Bind the checkbox to that column, and use an event to enable/disable the appropriate controls as each record is loaded, based on the setting of that column.

It's been ages (thankfully) since I had to code in VB, so I don't remember the exact name of the event. I think it was something like "OnNextRecord" or something like that.[/quote4c30afb441]

Hmmm, now I gotta remember how to do that, lol. What I'm seeing, if I understand YOU right, is that I can't toggle the checkbox from the form, but I can through the table. But when I toggle it through the table, the items in the form aren't disabled.

My head hurts. ( I'll mess with it more tomorrow, it's quitting time now. D

dmorris68

30-11-2006 19:09:46

The checkbox value would be loaded from the table, and the users would use the checkbox control to close the project.

There are numerous event handlers in VBA that get called when certain events happen. Several of these are database related. You just add some code to that event handler, or assign a function to the event handler. I just went and looked up the event that fires when a new record is loaded, or a Form is refreshed. It's the [b5cf5a96ca1]Current[/b5cf5a96ca1] event of the [b5cf5a96ca1]Form[/b5cf5a96ca1] object. Here is the VBA reference for the Current event

http//msdn2.microsoft.com/en-us/library/aa211356(office.11).aspx

So, taking this approach, you could add a boolean field to the project record table that represents the project's opened/closed state. Call it [i5cf5a96ca1]projectClosed[/i5cf5a96ca1] or something similarly logical. Add a checkbox control to your form that is bound to the boolean field (just like your other DB controls). In the Form's Current event, you check this boolean field (or the state of the checkbox, which is bound to the field and checks/unchecks based on the field value in the table). If the project is open, the field will be false and the checkbox unchecked. If they check the box to close the project, you can handle that in a Click or Change event on the checkbox control -- if so, you disable all the DB edit controls on the form. If you want users to be able to re-open and edit a project after it's been closed, then you leave the checkbox enabled always, allowing them to uncheck it, and again your checkbox Click/Change event handler would then enable the other controls for edit. If you want all projects to be closed permanently, then you also disable the checkbox when it's checked in the table.

jadem

01-12-2006 12:28:09

Thanks so much! ) Worked like a charm. It's all coming back to me lishudderli lol

dmorris68

01-12-2006 14:16:47

[quote9391def630="jadem"]Thanks so much! ) Worked like a charm. It's all coming back to me lishudderli lol[/quote9391def630]
Cool! Glad it worked.

Now go write it in a real language like Java, with a low-footprint SQL database like HSQL or Derby! P

jadem

02-12-2006 07:16:47

[quote0dde06011b="dmorris68"][quote0dde06011b="jadem"]Thanks so much! ) Worked like a charm. It's all coming back to me lishudderli lol[/quote0dde06011b]
Cool! Glad it worked.

Now go write it in a real language like Java, with a low-footprint SQL database like HSQL or Derby! P[/quote0dde06011b]

Smart ass...I once wrote in Java, when I was a CS major, but I hated coding and didn't want to do it for a living.

Then again, I still know some C programming skills...doesn't that count for something? ;P

dmorris68

02-12-2006 13:10:00

[quote821c8e20ba="jadem"][quote821c8e20ba="dmorris68"][quote821c8e20ba="jadem"]Thanks so much! ) Worked like a charm. It's all coming back to me lishudderli lol[/quote821c8e20ba]
Cool! Glad it worked.

Now go write it in a real language like Java, with a low-footprint SQL database like HSQL or Derby! P[/quote821c8e20ba]

Smart ass...I once wrote in Java, when I was a CS major, but I hated coding and didn't want to do it for a living.

Then again, I still know some C programming skills...doesn't that count for something? ;P[/quote821c8e20ba]
I guess you can slide then. ;)

C/C++ was my bread & butter for 20 years. Been doing almost exclusively Java for the last few years, though. Lovin' it.