Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: value of a row in a subform


Message #1 by "Sanna Korpela" <sanna.m.korpela@l...> on Thu, 16 Aug 2001 09:30:07
I have this form with customervisits and a subform of our workers who made 

the visit. I should make a button for deleting a worker selected my the 

user. I havent been able to get the id of the selected worker from this 

subform. I have tried to find a way to use Accesses own recordselector but 

I don't know if it even has a property of this id. I also tried to make a 

optionbox but it didn't work. 

My subforms defaultview is set to 'continuing form', or something like 

that.

Thank you,

Sanna
Message #2 by "Mark Irvine" <markpirvine@b...> on Thu, 16 Aug 2001 10:44:38 +0100
Sanna,



I have a similar set-up, in that I have a company form and the a subform

that holds credit entries.  To delete an entry from the subform I place a

delete button on the subform and used the following code:



Dim recSub As Recordset

Dim intSubTotalRecords As Integer

Dim intSubUserResponse As Integer

Dim strSubUserConfirm As String



strSubUserConfirm = "Are you sure you want to delete this credit record?"

intSubUserResponse = MsgBox(strSubUserConfirm, vbQuestion + vbOKCancel +

vbDefaultButton2, "The Corporate Wardrobe: Credit Analysis")



If (intSubUserResponse = vbOK) Then

    Set recSub = Me.Recordset

        With recSub

        .Delete

        intSubTotalRecords = .RecordCount

        If (intSubTotalRecords > 0) Then

            If intSubTotalRecords = 1 Then

                .MoveFirst

            Else

                .MovePrevious

            End If

        End If

    End With

End If



Hope this helps



Sanna Korpela <sanna.m.korpela@l...> wrote in message news:93974@a...

>

> I have this form with customervisits and a subform of our workers who made

> the visit. I should make a button for deleting a worker selected my the

> user. I havent been able to get the id of the selected worker from this

> subform. I have tried to find a way to use Accesses own recordselector but

> I don't know if it even has a property of this id. I also tried to make a

> optionbox but it didn't work.

> My subforms defaultview is set to 'continuing form', or something like

> that.

> Thank you,

> Sanna

>

>





Message #3 by "Sanna Korpela" <sanna.m.korpela@l...> on Thu, 16 Aug 2001 11:13:05
Hi Mark!

Thank you for replying so quickly to my message. Your code makes sense. I 

copiend it to a button in a subform below bethod Click, but nothing 

happens when I click the button. I mean absolutely nothing, not even that 

msgbox. Only thing I changed in that code was this last line in a msgbox 

which I supposed is the title of the box. Do you know what could be wrong?

Thanks,

Sanna
Message #4 by "Mark Irvine" <markpirvine@b...> on Thu, 16 Aug 2001 11:48:16 +0100
Sanna,



This happened to me a while back.  The problem was that the code was in a

function as part of a module.  All I did was copy the code into the event

handler for the button.  Do you have any error trapping code, this also

happened to me.  In that there was an error before the 'deleting' code and

as a result the sub was exited.  Apart from these few suggestions I am

unsure what is going wrong, if you want to forward the code I could take a

look at it.



Mark



Sanna Korpela <sanna.m.korpela@l...> wrote in message news:94041@a...

>

> Hi Mark!

> Thank you for replying so quickly to my message. Your code makes sense. I

> copiend it to a button in a subform below bethod Click, but nothing

> happens when I click the button. I mean absolutely nothing, not even that

> msgbox. Only thing I changed in that code was this last line in a msgbox

> which I supposed is the title of the box. Do you know what could be wrong?

> Thanks,

> Sanna

>

>





Message #5 by "Sanna Korpela" <sanna.m.korpela@l...> on Thu, 16 Aug 2001 12:02:15
Hi Mark!

Here is the code in it's whole. I have had problems with other objects 

click-function also. They just don't start running when I click them. I 

don't know if there is something wrong with Acces in my computer or what. 

But this firs line ("Private Sub...") is suggested by Access so I think 

there should be nothing wrong with that.



Private Sub cmdpoista_tekija_Click()

    Dim recSub As Recordset

    Dim intSubTotalRecords As Integer

    Dim intSubUserResponse As Integer

    Dim strSubUserConfirm As String



    strSubUserConfirm = "Haluatko varmasti poistaa valitun tekijän tästä 

työstä?"

    intSubUserResponse = MsgBox(strSubUserConfirm, vbQuestion + vbOKCancel 

+ vbDefaultButton2, "Mikrotukihenkilön poisto")



    If (intSubUserResponse = vbOK) Then

        Set recSub = Me.Recordset

            With recSub

            .Delete

            intSubTotalRecords = .RecordCount

            If (intSubTotalRecords > 0) Then

                If intSubTotalRecords = 1 Then

                    .MoveFirst

                Else

                    .MovePrevious

                End If

            End If

        End With

    End If



End Sub



> Sanna,

> 

> This happened to me a while back.  The problem was that the code was in a

> function as part of a module.  All I did was copy the code into the event

> handler for the button.  Do you have any error trapping code, this also

> happened to me.  In that there was an error before the 'deleting' code 

and

> as a result the sub was exited.  Apart from these few suggestions I am

> unsure what is going wrong, if you want to forward the code I could take 

a

> look at it.

> 

> Mark

Message #6 by "Mark Irvine" <markpirvine@b...> on Thu, 16 Aug 2001 16:11:09 +0100
Sanna,



I got your code and put it into a test database.  However I am getting a

Type mismatch error on the Set recSub = Me.Recordset statement!! I don't

understand this.  I will keep looking at it, just to let you know that I am

still on it.  Let me know if you have any joy.



Mark

Sanna Korpela <sanna.m.korpela@l...> wrote in message news:94056@a...

>

> Hi Mark!

> Here is the code in it's whole. I have had problems with other objects

> click-function also. They just don't start running when I click them. I

> don't know if there is something wrong with Acces in my computer or what.

> But this firs line ("Private Sub...") is suggested by Access so I think

> there should be nothing wrong with that.

>

> Private Sub cmdpoista_tekija_Click()

>     Dim recSub As Recordset

>     Dim intSubTotalRecords As Integer

>     Dim intSubUserResponse As Integer

>     Dim strSubUserConfirm As String

>

>     strSubUserConfirm = "Haluatko varmasti poistaa valitun tekijän tästä

> työstä?"

>     intSubUserResponse = MsgBox(strSubUserConfirm, vbQuestion + vbOKCancel

> + vbDefaultButton2, "Mikrotukihenkilön poisto")

>

>     If (intSubUserResponse = vbOK) Then

>         Set recSub = Me.Recordset

>             With recSub

>             .Delete

>             intSubTotalRecords = .RecordCount

>             If (intSubTotalRecords > 0) Then

>                 If intSubTotalRecords = 1 Then

>                     .MoveFirst

>                 Else

>                     .MovePrevious

>                 End If

>             End If

>         End With

>     End If

>

> End Sub

>

> > Sanna,

> >

> > This happened to me a while back.  The problem was that the code was in

a

> > function as part of a module.  All I did was copy the code into the

event

> > handler for the button.  Do you have any error trapping code, this also

> > happened to me.  In that there was an error before the 'deleting' code

> and

> > as a result the sub was exited.  Apart from these few suggestions I am

> > unsure what is going wrong, if you want to forward the code I could take

> a

> > look at it.

> >

> > Mark

>

>





Message #7 by "Sanna Korpela" <sanna.m.korpela@l...> on Fri, 17 Aug 2001 09:33:19
Hello Mark



Thank you for your help! Now I wound totally different kind of solution 

for the problem. The thing was that I tried to select a row from a subform 

to be deleted, now I have a subform showing only one row at the time, and 

then I use the own delete button of Access made by wizard. It is not what 

I wanted in the firstplace but this solution is similar with other forms 

in the same program, so maybe it's ok.

Good luck with your own projects and thanks again,

Sanna



> Sanna,

> 

> I got your code and put it into a test database.  However I am getting a

> Type mismatch error on the Set recSub = Me.Recordset statement!! I don't

> understand this.  I will keep looking at it, just to let you know that I 

am

> still on it.  Let me know if you have any joy.

> 

> Mark


  Return to Index