Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Searching/Modifying/Deleting Records on a Subform

Geek News

Searching/Modifying/Deleting Records on a Subform
"L.A. Lawyer" <kapplaw[ at ]linkline.com> 12/12/2008 9:33:30 PM
I want to be to change or delete records on a subform based on whether or
not they contain certain text strings.

How do "search" for the relative records (i.e., the records that contain
certain strings)?

How do I obtain the ItemID from that record?

How do I change the value of one or more fields in that record?

How do I delete the record if that is appropriate?

Thanks!


Re: Searching/Modifying/Deleting Records on a Subform
"Arvin Meyer [MVP]" <arvinm[ at ]mvps.invalid> 12/13/2008 2:06:52 AM
"L.A. Lawyer" <kapplaw[ at ]linkline.com> wrote in message
news:e$0vIFKXJHA.5328[ at ]TK2MSFTNGP05.phx.gbl...
[Quoted Text]
>I want to be to change or delete records on a subform based on whether or
> not they contain certain text strings.
>
> How do "search" for the relative records (i.e., the records that contain
> certain strings)?
>
> How do I obtain the ItemID from that record?

Select the record. Use an event to refer to the ItemID, like:

Sub Form_AfterInsert()
DoCmd.RunCommand acCmdSaveRecord
Debug.Print Me.ItemID
End Sub

> How do I change the value of one or more fields in that record?

Put the cursor in the textbox, use the Delete or Backspace key.

> How do I delete the record if that is appropriate?

Select the record, and hit the Delete key.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Re: Searching/Modifying/Deleting Records on a Subform
"L.A. Lawyer" <kapplaw[ at ]linkline.com> 12/13/2008 2:46:49 AM
I was clearly not clear: I want to do each of these steps programmatically.
How do I programatically obtain the ItemID of a record on the subform by the
content of a field in the record? I then want to replace that with
different text, which will change base on other criteria.


"Arvin Meyer [MVP]" <arvinm[ at ]mvps.invalid> wrote in message
news:utj34dMXJHA.4384[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text]
> "L.A. Lawyer" <kapplaw[ at ]linkline.com> wrote in message
> news:e$0vIFKXJHA.5328[ at ]TK2MSFTNGP05.phx.gbl...
>>I want to be to change or delete records on a subform based on whether or
>> not they contain certain text strings.
>>
>> How do "search" for the relative records (i.e., the records that contain
>> certain strings)?
>>
>> How do I obtain the ItemID from that record?
>
> Select the record. Use an event to refer to the ItemID, like:
>
> Sub Form_AfterInsert()
> DoCmd.RunCommand acCmdSaveRecord
> Debug.Print Me.ItemID
> End Sub
>
>> How do I change the value of one or more fields in that record?
>
> Put the cursor in the textbox, use the Delete or Backspace key.
>
>> How do I delete the record if that is appropriate?
>
> Select the record, and hit the Delete key.
> --
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.mvps.org/access
> http://www.accessmvp.com
>


Re: Searching/Modifying/Deleting Records on a Subform
"Arvin Meyer [MVP]" <arvinm[ at ]mvps.invalid> 12/13/2008 4:04:46 AM
From the main form refer to a control in the subform like:

Me.NameOfSubFormControl.Form.ItemID

from a subform refer to a control on the mainform like:

Me.Parent.ItemID

So from the main form:

Sub txtWhatever_AfterUpdate()
If Me.txtWhatever > 4 Then
Me.SubformControlName.Form.txtItemDescr = "What Me Worry?"
End Sub
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"L.A. Lawyer" <kapplaw[ at ]linkline.com> wrote in message
news:%23eGsQ0MXJHA.5108[ at ]TK2MSFTNGP04.phx.gbl...
[Quoted Text]
>I was clearly not clear: I want to do each of these steps programmatically.
>How do I programatically obtain the ItemID of a record on the subform by
>the content of a field in the record? I then want to replace that with
>different text, which will change base on other criteria.
>
>
> "Arvin Meyer [MVP]" <arvinm[ at ]mvps.invalid> wrote in message
> news:utj34dMXJHA.4384[ at ]TK2MSFTNGP03.phx.gbl...
>> "L.A. Lawyer" <kapplaw[ at ]linkline.com> wrote in message
>> news:e$0vIFKXJHA.5328[ at ]TK2MSFTNGP05.phx.gbl...
>>>I want to be to change or delete records on a subform based on whether or
>>> not they contain certain text strings.
>>>
>>> How do "search" for the relative records (i.e., the records that contain
>>> certain strings)?
>>>
>>> How do I obtain the ItemID from that record?
>>
>> Select the record. Use an event to refer to the ItemID, like:
>>
>> Sub Form_AfterInsert()
>> DoCmd.RunCommand acCmdSaveRecord
>> Debug.Print Me.ItemID
>> End Sub
>>
>>> How do I change the value of one or more fields in that record?
>>
>> Put the cursor in the textbox, use the Delete or Backspace key.
>>
>>> How do I delete the record if that is appropriate?
>>
>> Select the record, and hit the Delete key.
>> --
>> Arvin Meyer, MCP, MVP
>> http://www.datastrat.com
>> http://www.mvps.org/access
>> http://www.accessmvp.com
>>
>
>


Re: Searching/Modifying/Deleting Records on a Subform
John W. Vinson <jvinson[ at ]STOP_SPAM.WysardOfInfo.com> 12/13/2008 6:38:37 AM
On Fri, 12 Dec 2008 18:46:49 -0800, "L.A. Lawyer" <kapplaw[ at ]linkline.com>
wrote:

[Quoted Text]
>I was clearly not clear: I want to do each of these steps programmatically.
>How do I programatically obtain the ItemID of a record on the subform by the
>content of a field in the record? I then want to replace that with
>different text, which will change base on other criteria.

Bear in mind that the Subform *does not contain any data*.

The data is stored in a Table; the subform is only a window, a way to view the
table.

It sounds like you want to run an update query (or a delete query, or
whatever) on that table based on some criteria, and then requery the subform
to display the changed table contents.
--

John W. Vinson [MVP]

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net