Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with update funtion

Status
Not open for further replies.

JavaToPerlNowVB

Programmer
Joined
Jul 14, 2005
Messages
84
Location
US
I have this code in in my form
Code:
Private Sub WorkOrderUpdate_button_Click()
On Err GoTo err_WorkOrderUpdate_button_click

    Dim updateQryPole As String
    Dim updateQryPed, updateQrySWTGR, updateQryXFMR As String
    Dim searchWOnumPole As Variant
    Dim searchWOnumPed As Variant
    Dim searchWOnumTrans As Variant
    Dim searchWOnumSwitch As Variant
    
    searchWOnumPole = DLookup("[WO]", "QueryMaintPole", "[WO] = WorkOrderUpdate_Text")
    searchWOnumPed = DLookup("[WO]", "QueryMaintPed", "[WO] = WorkOrderUpdate_Text")
    searchWOnumTrans = DLookup("[WO]", "QueryMaintXFMR", "[WO] = WorkOrderUpdate_Text")
    searchWOnumSwitch = DLookup("[WO]", "QueryMaintSWTGR", "[WO] = WorkOrderUpdate_Text")

    If IsNull(WorkOrderUpdate_Text) Then
        MsgBox "Please enter Work Order"
        Exit Sub
    ElseIf IsNull(New_WorkOrder_Text) Then
        MsgBox "Please enter new work order"
        Exit Sub
    End If
    
    'Checking the workorder number for each table
    
        If searchWOnumPole = WorkOrderUpdate_Text And updatePole Then
            MsgBox "poleNum " & searchWOnumPole
            updateQryPole = "UpdateQueryMaintPole"
            DoCmd.OpenQuery updateQryPole, acViewNormal, acEdit
        ElseIf IsNull(updatePole) Then
            MsgBox "Please select a table to update"
        Else
            MsgBox "Invalid Pole number"
        End If
[COLOR=red]    
        If searchWOnumPed = WorkOrderUpdate_Text And UpdatePed Then [/color]
            MsgBox "Checking if bothConditions ard ok"
            'updateQryPed = "UpdateQueryMaintPed"
            'DoCmd.OpenQuery updateQryPed, acViewNormal, asEdit
        ElseIf IsNull(UpdatePed) Then
            MsgBox "Please select a table to update"
        Else
            MsgBox "Invalid Pedestrial number"
        End If
    
        'If searchWOnumSwitch Then
            'updateQrySWTGR = "UpdateQueryMaintSWTGR"
            'DoCmd.OpenQuery updateQrySWTGR, acViewNormal, acEdit
        'End If
    
        'If searchWOnumTrans Then
            'updateQryXFMR = "UpdateQueryMaintXFMR"
            'DoCmd.OpenQuery updateQryXFMR, acViewNormal, acEdit
        'End If
   
    
exit_WorkOrderUpdate_button_click:
Exit Sub

err_WorkOrderUpdate_button_click:
    MsgBox Err.Description
    Resume exit_WorkOrderUpdate_button_click
        
End Sub

I get an error on the line If searchWOnumPed = WorkOrderUpdate_Text And UpdatePed Then (red color line)
it says object doesn't support this property or method
thanks
 
What is UpdatePed? Does it return a boolean value?
If you take out the first condition, does it run?
If you then take out the second condition and leave the first one, does it run?

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Anyway I wonder the DlookUp are correct.
I'd replace the 4
"[WO] = WorkOrderUpdate_Text"
By
"[WO] = " & WorkOrderUpdate_Text
Or
"[WO] = '" & WorkOrderUpdate_Text & "'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
also I'd put this chunk of code FIRST before anything else:

If IsNull(WorkOrderUpdate_Text) Then
MsgBox "Please enter Work Order"
me.[WorkOrderUpdate_Text].setfocus
Exit Sub
ElseIf IsNull(New_WorkOrder_Text) Then
MsgBox "Please enter new work order"
me.[New_Workorder_Text].setfocus
Exit Sub
End If


otherwise you're wasting time.

you can also setfocus into the text box for the users' convenience:

Me.WorkOrderUpdate_Text.SetFocus

before exit sub

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Thanks everybody finally all the updates are working fine thanks alot for all the help
 
Can you post the solution so others might benefit?

Thanks!

g

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
sure..where should i put it I am new to this site should i put it in a faq or something like that......
 
Simply in your next reply to this thread...
 
Private Sub WorkOrderUpdate_button_Click()
On Err GoTo err_WorkOrderUpdate_button_click

Dim updateQryPole As String
Dim updateQryPed, updateQrySWTGR, updateQryXFMR As String
Dim searchWOnumPole As Variant
Dim searchWOnumPed As Variant
Dim searchWOnumTrans As Variant
Dim searchWOnumSwitch As Variant

searchWOnumPole = DLookup("[WO]", "QueryMaintPole", "[WO] = '" & WorkOrderUpdate_Text & "'")
searchWOnumPed = DLookup("[WO]", "QueryMaintPed", "[WO] = '" & WorkOrderUpdate_Text & "'")
searchWOnumTrans = DLookup("[WO]", "QueryMaintXFMR", "[WO] = '" & WorkOrderUpdate_Text & "'")
searchWOnumSwitch = DLookup("[WO]", "QueryMaintSWTGR", "[WO] = '" & WorkOrderUpdate_Text & "'")

If IsNull(WorkOrderUpdate_Text) Then
MsgBox "Please enter Work Order"
Me.WorkOrderUpdate_Text.SetFocus
Exit Sub
ElseIf IsNull(New_WorkOrder_Text) Then
MsgBox "Please enter new work order"
Me.New_WorkOrder_Text.SetFocus
Exit Sub
End If

'Checking the workorder number for each table

If searchWOnumPole = WorkOrderUpdate_Text And updatePole Then
MsgBox "poleNum " & searchWOnumPole
updateQryPole = "UpdateQueryMaintPole"
DoCmd.OpenQuery updateQryPole, acViewNormal, acEdit
ElseIf IsNull((updatePole) And IsNull(update_Ped) And IsNull(updateTransform)) Then
MsgBox "Please select a table to update - pole"
Else
'MsgBox "Invalid Pole number"
End If

If searchWOnumPed = WorkOrderUpdate_Text And update_Ped Then
updateQryPed = "UpdateQueryMaintPed"
DoCmd.OpenQuery updateQryPed, acViewNormal, acEdit
ElseIf IsNull((update_Ped) And IsNull(updatePole) And IsNull(updateTransform)) Then
MsgBox "Please select a table to update"
Else
'MsgBox "Invalid Pedestrial Number"
End If

If searchWOnumTrans = WorkOrderUpdate_Text And updateTransform Then
updateQryXFMR = "UpdateQueryMaintXFMR"
DoCmd.OpenQuery updateQryXFMR, acViewNormal, acEdit
ElseIf IsNull((updatePole) And IsNull(UpdatePed) And IsNull(updateTransform)) Then
MsgBox "Please select a table to update - Trans"
End If

If searchWOnumSwitch = WorkOrderUpdate_Text And updateSwitch Then
updateQrySWTGR = "UpdateQueryMaintSWTGR"
DoCmd.OpenQuery updateQrySWTGR, acViewNormal, acEdit
ElseIf IsNull((updateSwitch) And IsNull(updateTransform) And IsNull(updatePole) And IsNull(update_Ped)) Then
MsgBox "Please Select a Table to Update"
End If

exit_WorkOrderUpdate_button_click:
Exit Sub

err_WorkOrderUpdate_button_click:
MsgBox Err.Description
Resume exit_WorkOrderUpdate_button_click

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top