Chaning Forms

N

Nylex

When entering into a sub form if a certain condition is met I have to send
them back to the main form - How do I do it
Main Form "Vehicle"
Sub Form "VehicleModel"
I have tried goto control setfocus active etc'
But the cursor always go's back to the field it came from or the next field
in the subform - never the main form
I have asked this question before but the answer had nothing in the text
 
J

John W. Vinson

When entering into a sub form if a certain condition is met I have to send
them back to the main form - How do I do it
Main Form "Vehicle"
Sub Form "VehicleModel"
I have tried goto control setfocus active etc'
But the cursor always go's back to the field it came from or the next field
in the subform - never the main form
I have asked this question before but the answer had nothing in the text

I believe that you need to do this in two steps:

Parent.SetFocus
Parent!controlname.SetFocus
 
N

Nylex

Private Sub ModelName_Enter()
Dim StrName As String
Dim i As Integer
Dim Msg As String
StrName = Nz(Me.Parent![VehDesc])
If StrName = "" Then GoTo 100
GoTo 200
100
Msg = "'" & "' No Vehicle Name is Selected."
Msg = Msg & " - Select Vehicle Name"

i = MsgBox(Msg, vbQuestion + vbYesonly, "Unknown Vehicle...")
Response = acDataErrContinue

Parent.SetFocus
Parent!VehDesc.SetFocus (stops here)


200 Exit Sub

End Sub

Run-Time Error '438'
Object doesnt support this property or method

Tks for you continued help
 
R

Rick A.B.

Private Sub ModelName_Enter()
    Dim StrName As String
    Dim i As Integer
    Dim Msg As String
    StrName = Nz(Me.Parent![VehDesc])
    If StrName = "" Then GoTo 100
    GoTo 200
100
    Msg = "'" & "' No Vehicle Name is Selected."
    Msg = Msg & " - Select Vehicle Name"

    i = MsgBox(Msg, vbQuestion + vbYesonly, "Unknown Vehicle...")
        Response = acDataErrContinue

    Parent.SetFocus
    Parent!VehDesc.SetFocus (stops here)

200 Exit Sub

End Sub

Run-Time Error '438'
Object doesnt support this property or method

Tks for you continued help
Just took a quick glance at this and it looks like your declaring i as
an integer and trying to assign a string to it.
 
S

Stuart McCall

Private Sub ModelName_Enter()
Dim StrName As String
Dim i As Integer
Dim Msg As String
StrName = Nz(Me.Parent![VehDesc])
If StrName = "" Then GoTo 100
GoTo 200
100
Msg = "'" & "' No Vehicle Name is Selected."
Msg = Msg & " - Select Vehicle Name"

i = MsgBox(Msg, vbQuestion + vbYesonly, "Unknown Vehicle...")
Response = acDataErrContinue

Parent.SetFocus
Parent!VehDesc.SetFocus (stops here)

200 Exit Sub

End Sub

Run-Time Error '438'
Object doesnt support this property or method

Tks for you continued help

Just took a quick glance at this and it looks like your declaring i as
an integer and trying to assign a string to it.

Rick: The return from the MsgBox function is actually an integer, in this
case vbYes (6) or vbNo (7).

Nylex: When the line:

StrName = Nz(Me.Parent![VehDesc])

has executed, do you get a value in StrName? If so then your line:

Parent!VehDesc.SetFocus

should work. Look carefully at your main form control name and make sure it
reads *exactly* VehDesc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top