Open forms based on criteria

  • Follow


Hi

I have 3 forms "Work_in_progress", "Installations" and Warranty".

Form  "Work_in_progress" is a continuous form that displays uncompleted 
work, each line has a control "Update" when pressed it opens form 
"Installations" which until recently was fine. We have now secured a contract 
to carryout warranty repairs, which requires a different form to be completed 
("Warranty").

The 3 forms has "Tbl_Customers" as their control source which has a field 
"Job_Type" this would contain the following data "Installations or Warranty".

What I would like to achieve is that when the control "Update" is pressed it 
will open either of the forms "Installations" or "Warranty" based on the data 
in "Tbl_Customers" field "Job_Type".

Example -- When field "Job_Type" = "Warranty" form "Warranty" is opened

I have searched through the posts but cannot find a solution.

Can someone provide an answer.

Thanks
Bazmac
0
Reply Utf 4/2/2010 12:26:03 AM

You need to change the recordsource of the form to a query in order to add 
the Job_Type to the form. Then you need to branch the code with an If ... 
Then ... Else statement or a Select Case statement. Here's an aircode 
snippet:

If Me.txtJob_Type = "Installantion" Then    ' or the Job_TypeID
    DoCmd.OpenForm "Form1",,, "JobID = " & Me.txtJobID
Else
    DoCmd.OpenForm "Form2",,, "JobID = " & Me.txtJobID
End If
-- 
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access


"Bazmac" <Bazmac@discussions.microsoft.com> wrote in message 
news:659ED65A-6434-46E0-9F3F-459985826914@microsoft.com...
> Hi
>
> I have 3 forms "Work_in_progress", "Installations" and Warranty".
>
> Form  "Work_in_progress" is a continuous form that displays uncompleted
> work, each line has a control "Update" when pressed it opens form
> "Installations" which until recently was fine. We have now secured a 
> contract
> to carryout warranty repairs, which requires a different form to be 
> completed
> ("Warranty").
>
> The 3 forms has "Tbl_Customers" as their control source which has a field
> "Job_Type" this would contain the following data "Installations or 
> Warranty".
>
> What I would like to achieve is that when the control "Update" is pressed 
> it
> will open either of the forms "Installations" or "Warranty" based on the 
> data
> in "Tbl_Customers" field "Job_Type".
>
> Example -- When field "Job_Type" = "Warranty" form "Warranty" is opened
>
> I have searched through the posts but cannot find a solution.
>
> Can someone provide an answer.
>
> Thanks
> Bazmac 


0
Reply Arvin 4/2/2010 1:38:50 AM


Arvin,

Thankyou for your quick reply I have tried your suggestion the outcome is 
that "Warranty" is the only form to display regardless of job type chosen, 
please find below the original on click procedure follwed by your suggestion.

Could you advise were the problem is in the code

Thanking You
Bazmac

Private Sub Update_Click()
On Error GoTo Err_Update_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    
    stDocName = "Installation"
    
    stLinkCriteria = "[JobNo]=" & "'" & Me![JobNo] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    
Exit_Update_Click:
    Exit Sub

Err_Update_Click:
    MsgBox Err.Description
    Resume Exit_Update_Click
  
 
End Sub

Private Sub Update_Click()
On Error GoTo Err_Update_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    
    'stDocName = "Installation"
    
    'stLinkCriteria = "[JobNo]=" & "'" & Me![JobNo] & "'"
    'DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    If Me.Job_Type = "Installantion" Then    ' or the Job_TypeID
    DoCmd.OpenForm "Installation", , , "[JobNo]=" & "'" & Me![JobNo] & "'"
Else
    DoCmd.OpenForm "Warranty", , , "[JobNo]=" & "'" & Me![JobNo] & "'"
End If

    
Exit_Update_Click:
    Exit Sub

Err_Update_Click:
    MsgBox Err.Description
    Resume Exit_Update_Click
  
 
End Sub


"Arvin Meyer [MVP]" wrote:

> You need to change the recordsource of the form to a query in order to add 
> the Job_Type to the form. Then you need to branch the code with an If ... 
> Then ... Else statement or a Select Case statement. Here's an aircode 
> snippet:
> 
> If Me.txtJob_Type = "Installantion" Then    ' or the Job_TypeID
>     DoCmd.OpenForm "Form1",,, "JobID = " & Me.txtJobID
> Else
>     DoCmd.OpenForm "Form2",,, "JobID = " & Me.txtJobID
> End If
> -- 
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.accessmvp.com
> http://www.mvps.org/access
> 
> 
> "Bazmac" <Bazmac@discussions.microsoft.com> wrote in message 
> news:659ED65A-6434-46E0-9F3F-459985826914@microsoft.com...
> > Hi
> >
> > I have 3 forms "Work_in_progress", "Installations" and Warranty".
> >
> > Form  "Work_in_progress" is a continuous form that displays uncompleted
> > work, each line has a control "Update" when pressed it opens form
> > "Installations" which until recently was fine. We have now secured a 
> > contract
> > to carryout warranty repairs, which requires a different form to be 
> > completed
> > ("Warranty").
> >
> > The 3 forms has "Tbl_Customers" as their control source which has a field
> > "Job_Type" this would contain the following data "Installations or 
> > Warranty".
> >
> > What I would like to achieve is that when the control "Update" is pressed 
> > it
> > will open either of the forms "Installations" or "Warranty" based on the 
> > data
> > in "Tbl_Customers" field "Job_Type".
> >
> > Example -- When field "Job_Type" = "Warranty" form "Warranty" is opened
> >
> > I have searched through the posts but cannot find a solution.
> >
> > Can someone provide an answer.
> >
> > Thanks
> > Bazmac 
> 
> 
> .
> 
0
Reply Utf 4/2/2010 2:55:01 AM

Could it be the typo?

If Me.Job_Type = "Installantion" Then

Installantion <> Installation

-- 
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access


"Bazmac" <Bazmac@discussions.microsoft.com> wrote in message 
news:8EDA1760-FCE7-4DF5-8973-3C353DB24830@microsoft.com...
> Arvin,
>
> Thankyou for your quick reply I have tried your suggestion the outcome is
> that "Warranty" is the only form to display regardless of job type chosen,
> please find below the original on click procedure follwed by your 
> suggestion.
>
> Could you advise were the problem is in the code
>
> Thanking You
> Bazmac
>
> Private Sub Update_Click()
> On Error GoTo Err_Update_Click
>
>    Dim stDocName As String
>    Dim stLinkCriteria As String
>
>    stDocName = "Installation"
>
>    stLinkCriteria = "[JobNo]=" & "'" & Me![JobNo] & "'"
>    DoCmd.OpenForm stDocName, , , stLinkCriteria
>
>
> Exit_Update_Click:
>    Exit Sub
>
> Err_Update_Click:
>    MsgBox Err.Description
>    Resume Exit_Update_Click
>
>
> End Sub
>
> Private Sub Update_Click()
> On Error GoTo Err_Update_Click
>
>    Dim stDocName As String
>    Dim stLinkCriteria As String
>
>    'stDocName = "Installation"
>
>    'stLinkCriteria = "[JobNo]=" & "'" & Me![JobNo] & "'"
>    'DoCmd.OpenForm stDocName, , , stLinkCriteria
>
>    If Me.Job_Type = "Installantion" Then    ' or the Job_TypeID
>    DoCmd.OpenForm "Installation", , , "[JobNo]=" & "'" & Me![JobNo] & "'"
> Else
>    DoCmd.OpenForm "Warranty", , , "[JobNo]=" & "'" & Me![JobNo] & "'"
> End If
>
>
> Exit_Update_Click:
>    Exit Sub
>
> Err_Update_Click:
>    MsgBox Err.Description
>    Resume Exit_Update_Click
>
>
> End Sub
>
>
> "Arvin Meyer [MVP]" wrote:
>
>> You need to change the recordsource of the form to a query in order to 
>> add
>> the Job_Type to the form. Then you need to branch the code with an If ...
>> Then ... Else statement or a Select Case statement. Here's an aircode
>> snippet:
>>
>> If Me.txtJob_Type = "Installantion" Then    ' or the Job_TypeID
>>     DoCmd.OpenForm "Form1",,, "JobID = " & Me.txtJobID
>> Else
>>     DoCmd.OpenForm "Form2",,, "JobID = " & Me.txtJobID
>> End If
>> -- 
>> Arvin Meyer, MCP, MVP
>> http://www.datastrat.com
>> http://www.accessmvp.com
>> http://www.mvps.org/access
>>
>>
>> "Bazmac" <Bazmac@discussions.microsoft.com> wrote in message
>> news:659ED65A-6434-46E0-9F3F-459985826914@microsoft.com...
>> > Hi
>> >
>> > I have 3 forms "Work_in_progress", "Installations" and Warranty".
>> >
>> > Form  "Work_in_progress" is a continuous form that displays uncompleted
>> > work, each line has a control "Update" when pressed it opens form
>> > "Installations" which until recently was fine. We have now secured a
>> > contract
>> > to carryout warranty repairs, which requires a different form to be
>> > completed
>> > ("Warranty").
>> >
>> > The 3 forms has "Tbl_Customers" as their control source which has a 
>> > field
>> > "Job_Type" this would contain the following data "Installations or
>> > Warranty".
>> >
>> > What I would like to achieve is that when the control "Update" is 
>> > pressed
>> > it
>> > will open either of the forms "Installations" or "Warranty" based on 
>> > the
>> > data
>> > in "Tbl_Customers" field "Job_Type".
>> >
>> > Example -- When field "Job_Type" = "Warranty" form "Warranty" is opened
>> >
>> > I have searched through the posts but cannot find a solution.
>> >
>> > Can someone provide an answer.
>> >
>> > Thanks
>> > Bazmac
>>
>>
>> .
>> 


0
Reply Arvin 4/2/2010 3:58:27 AM

Alvin,

Thankyou for your help this would have the worked first time if I could 
spell properly.(Installantion)

Bazmac

"Bazmac" wrote:

> Arvin,
> 
> Thankyou for your quick reply I have tried your suggestion the outcome is 
> that "Warranty" is the only form to display regardless of job type chosen, 
> please find below the original on click procedure follwed by your suggestion.
> 
> Could you advise were the problem is in the code
> 
> Thanking You
> Bazmac
> 
> Private Sub Update_Click()
> On Error GoTo Err_Update_Click
> 
>     Dim stDocName As String
>     Dim stLinkCriteria As String
>     
>     stDocName = "Installation"
>     
>     stLinkCriteria = "[JobNo]=" & "'" & Me![JobNo] & "'"
>     DoCmd.OpenForm stDocName, , , stLinkCriteria
>     
>     
> Exit_Update_Click:
>     Exit Sub
> 
> Err_Update_Click:
>     MsgBox Err.Description
>     Resume Exit_Update_Click
>   
>  
> End Sub
> 
> Private Sub Update_Click()
> On Error GoTo Err_Update_Click
> 
>     Dim stDocName As String
>     Dim stLinkCriteria As String
>     
>     'stDocName = "Installation"
>     
>     'stLinkCriteria = "[JobNo]=" & "'" & Me![JobNo] & "'"
>     'DoCmd.OpenForm stDocName, , , stLinkCriteria
>     
>     If Me.Job_Type = "Installantion" Then    ' or the Job_TypeID
>     DoCmd.OpenForm "Installation", , , "[JobNo]=" & "'" & Me![JobNo] & "'"
> Else
>     DoCmd.OpenForm "Warranty", , , "[JobNo]=" & "'" & Me![JobNo] & "'"
> End If
> 
>     
> Exit_Update_Click:
>     Exit Sub
> 
> Err_Update_Click:
>     MsgBox Err.Description
>     Resume Exit_Update_Click
>   
>  
> End Sub
> 
> 
> "Arvin Meyer [MVP]" wrote:
> 
> > You need to change the recordsource of the form to a query in order to add 
> > the Job_Type to the form. Then you need to branch the code with an If ... 
> > Then ... Else statement or a Select Case statement. Here's an aircode 
> > snippet:
> > 
> > If Me.txtJob_Type = "Installantion" Then    ' or the Job_TypeID
> >     DoCmd.OpenForm "Form1",,, "JobID = " & Me.txtJobID
> > Else
> >     DoCmd.OpenForm "Form2",,, "JobID = " & Me.txtJobID
> > End If
> > -- 
> > Arvin Meyer, MCP, MVP
> > http://www.datastrat.com
> > http://www.accessmvp.com
> > http://www.mvps.org/access
> > 
> > 
> > "Bazmac" <Bazmac@discussions.microsoft.com> wrote in message 
> > news:659ED65A-6434-46E0-9F3F-459985826914@microsoft.com...
> > > Hi
> > >
> > > I have 3 forms "Work_in_progress", "Installations" and Warranty".
> > >
> > > Form  "Work_in_progress" is a continuous form that displays uncompleted
> > > work, each line has a control "Update" when pressed it opens form
> > > "Installations" which until recently was fine. We have now secured a 
> > > contract
> > > to carryout warranty repairs, which requires a different form to be 
> > > completed
> > > ("Warranty").
> > >
> > > The 3 forms has "Tbl_Customers" as their control source which has a field
> > > "Job_Type" this would contain the following data "Installations or 
> > > Warranty".
> > >
> > > What I would like to achieve is that when the control "Update" is pressed 
> > > it
> > > will open either of the forms "Installations" or "Warranty" based on the 
> > > data
> > > in "Tbl_Customers" field "Job_Type".
> > >
> > > Example -- When field "Job_Type" = "Warranty" form "Warranty" is opened
> > >
> > > I have searched through the posts but cannot find a solution.
> > >
> > > Can someone provide an answer.
> > >
> > > Thanks
> > > Bazmac 
> > 
> > 
> > .
> > 
0
Reply Utf 4/2/2010 3:59:01 AM

4 Replies
224 Views

(page loaded in 0.146 seconds)

Similiar Articles:
















7/29/2012 11:01:13 PM


Reply: