Solved Quandary regarding continuous form (1 Viewer)

PaquettePaul

Member
Local time
Today, 12:59
Joined
Mar 28, 2022
Messages
107
I have two sub forms that show records for the master event. I would like a simple way for the user to select a record and then press a Delete command button to remove it.

i thought about having a Delete button in the form footer and a yes/no box for the record. However, when I select a non bound field, all the boxes went true or false. Wondering if I need to include a delete button on every record line in the form.

Guess I am looking for best practice for deletion in continuous forms. btw, in one more, all the fields are display only and on the other the data Is a full entry approach.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 03:59
Joined
Jan 20, 2009
Messages
12,849
A checkbox unbound to any table can be made to work independently on a form using a Disconnected ADODB Recordset.
However, as it is disconnected, any Updates and Deletes on the form must be managed in code.
BTW A checkbox can be faked using a textbox with a Wingding font and managed with Conditional Formatting.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:59
Joined
Feb 28, 2001
Messages
26,999
There is a rule in general programming about planning ahead by building in things you will need later. If you had a bound Y/N field, you could put a bound checkbox in the record and just check the things you want deleted. That would NOT check every box.

If you knew ahead of time you were going to do this, the idea would be to support your anticipated actions by having a way to select records for contemplated actions.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 03:59
Joined
Jan 20, 2009
Messages
12,849
here is a rule in general programming about planning ahead by building in things you will need later. If you had a bound Y/N field, you could put a bound checkbox in the record and just check the things you want deleted. That would NOT check every box.
Very bad idea. Every user would have the same checkboxes so user actions would apply to those records currently selected by any user.
 

PaquettePaul

Member
Local time
Today, 12:59
Joined
Mar 28, 2022
Messages
107
i had thought about that idea but discounted It because it would be intrusive into the database. Code is fine. I was thinking that the key of the record where the user has there cursor could be identified somehow and stored in a global key. When the user hits the delete button, the code could delete the record and requery the form.
 

PaquettePaul

Member
Local time
Today, 12:59
Joined
Mar 28, 2022
Messages
107
Some days, I just feel old and forgetful. Simple solutions.

I forgot about the record selector attribute. Switched that on for the two continuos forms. Now I have a way for the user to select a specific record, even those that are locked. When the record is selected, the OnCurrent routine is invoked where I store the key of the selected record into a global variable. Then, if the user clicks on the Delete command button, I have access to the current key and can take steps to remove the record and requery the form.

Thanks for the comments because it moved me away from a mindset that was not going to succeed. Watched some videos, saw record selectors used for something else, and the light went on. This thing has been rattling around in my head for a few weeks without a solution. Dropping a comment here seems to bring some of my problems into crisp focus for me. As always, your feedback is always welcome.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:59
Joined
Feb 28, 2001
Messages
26,999
Very bad idea. Every user would have the same checkboxes so user actions would apply to those records currently selected by any user.

I can build a local table that contains the check-boxes and PK's from the common table, then populate that continuous form with a JOIN query between the local and common tables. The check boxes would be local (non-shared) but with that JOIN I can make it look like they have bound checkboxes. Granted, I gave a short answer as a possible direction, but I know better than to make the checkboxes shared, G. And I stand by the other part of the advice - anticipate your requirements and build in your solutions before you need to retrofit them.
 

KitaYama

Well-known member
Local time
Tomorrow, 01:59
Joined
Jan 6, 2022
Messages
1,489
I can build a local table that contains the check-boxes and PK's from the common table, then populate that continuous form with a JOIN query between the local and common tables. The check boxes would be local (non-shared) but with that JOIN I can make it look like they have bound checkboxes. Granted, I gave a short answer as a possible direction, but I know better than to make the checkboxes shared, G. And I stand by the other part of the advice - anticipate your requirements and build in your solutions before you need to retrofit them.
@The_Doc_Man While I don't understand most of what you explained and I'm sure you can do what you said, but it's too much work for just deleting a record. Any table has a PK and when the cursor is in a record, in On_Click event of the button I can use :
CurrentDB.Excecute "Delete * FROM mytable Where PK=" & Me!PK
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:59
Joined
Feb 28, 2001
Messages
26,999
For a single-record case, true. What about multiple selections at once (which you can do by holding down SHIFT when you click the cursor)?

For a one-at-a time, you are perfectly right. For a many-at-once, that gets a bit more tricky.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:59
Joined
Feb 19, 2002
Messages
42,971
If the subform is in Continuous view, you can add buttons on the records themselves which I prefer. That makes it very clear to the user exactly which record he is deleting. That leaves your selected method of saving the ID of the current record and having the delete button on the mainform a choice but my second choice.

If the subform is in DS view, you can't add buttons. In that case, I add a dummy field to the form's RecordSource query and the field that contains the value "Delete". It is formatted using Conditional formatting to have a different background color based on the value of "Delete". Then clicking or the safer double-click can be used to delete the record.

Deletes are always dangerous and so when I allow them, I always include prompts.
 

Users who are viewing this thread

Top Bottom