JeffBarker
Registered User.
- Local time
- Today, 04:11
- Joined
- Dec 7, 2010
- Messages
- 130
Hi guys, this is a bit of a weird one, and probably more to do with my rubbish VBA skills than anything else, but I'm hoping someone is able to clarify either way!!
We use our CRM for entering client orders, which is done through our 'OrderEntry' form. On that form we have a subform that we use to enter order lines - as we have a range of products on offer, an order can be made up of one product or anything up to 100.
We have an 'amount' textbox on the subform, that the users enter the cost of each line, and as they add more lines the total cost of the order is calculated using a textbox in the subform Footer, with the ControlSource set to =Sum([amount]).
On the main form, we have a Net textbox, that the user will add in the total cost of the order once they've added all the order lines, and providing the =Sum([amount]) textbox on the subform matches the figure in the Net textbox, a button to Proceed the order and go on to the next step appears.
The intermittent problem I have, is that the OnCurrent event I use to show the Proceed button does not seem to fire on its own - but when I stop the code and step through it, it will show the Proceed button without any problems.
Here's the code:
(the Proceed button is referred to a 'Command80')
I've made the part that refers to the Proceed button bold, but thought I'd add in the whole OnCurrent event in case there was anything in there that was blocking it.
I added in the MsgBox code at the bottom to make sure the OnCurrent was firing, and that works fine.
I've searched through the rest of the code, and there's nothing else in there that references the Visible property of the button.
I've been through the decompile process detailed here, and also been through this similar thread with a fine toothcomb and this still won't work.
I've saved the form out as a textfile and then imported it back in, both through the immediate window, and short of importing everything in to a new DB and starting again, I'm actually pretty stumped!!
So any help will be most appreciated, thanks!
We use our CRM for entering client orders, which is done through our 'OrderEntry' form. On that form we have a subform that we use to enter order lines - as we have a range of products on offer, an order can be made up of one product or anything up to 100.
We have an 'amount' textbox on the subform, that the users enter the cost of each line, and as they add more lines the total cost of the order is calculated using a textbox in the subform Footer, with the ControlSource set to =Sum([amount]).
On the main form, we have a Net textbox, that the user will add in the total cost of the order once they've added all the order lines, and providing the =Sum([amount]) textbox on the subform matches the figure in the Net textbox, a button to Proceed the order and go on to the next step appears.
The intermittent problem I have, is that the OnCurrent event I use to show the Proceed button does not seem to fire on its own - but when I stop the code and step through it, it will show the Proceed button without any problems.
Here's the code:
(the Proceed button is referred to a 'Command80')
Code:
Dim OS As String
Dim UT As String
OS = OrderStatus
UT = fGetUserType
If Me.AccountsStatus = "account on stop" Then
Me.Command80.Visible = False
MsgBox "Account is on stop" & Chr(13) & "You can view orders but can not place orders for this customer.", vbInformation
End If
If [Main Function] = "Agency" Then
Client.Visible = True
Label73.Visible = True
Else
Client.Visible = False
Label73.Visible = False
End If
If Me.CanxReason > "" Then
Me.Text108.Visible = True
Command110.Visible = True
Command104.Visible = False
Me.OrderType.Locked = True
Me.InvoiceContact.Locked = True
Me.ProductionContact.Locked = True
Me.Client.Locked = True
Me.PO_Number.Locked = True
Me.Gross.Locked = True
Me.Discount.Locked = True
Me.Net.Locked = True
Me.Command52.Enabled = False
Me.Command53.Enabled = False
Me.Order_Detail.Enabled = False
Me.Production_Notes.Enabled = False
Me.Finance_Notes.Enabled = False
Me.tblAllocation_subform.Locked = True
Me.Command80.Enabled = False
Else
Me.Text108.Visible = False
Me.Command110.Visible = False
Me.Command104.Visible = True
Me.Label105.Visible = False
Me.CanxReason.Visible = False
Me.OrderType.Locked = False
Me.InvoiceContact.Locked = False
Me.ProductionContact.Locked = False
Me.Client.Locked = False
Me.PO_Number.Locked = False
Me.Gross.Locked = False
Me.Discount.Locked = False
Me.Net.Locked = False
Me.Command52.Enabled = True
Me.Command53.Enabled = True
Me.Order_Detail.Enabled = True
Me.Production_Notes.Enabled = True
Me.Finance_Notes.Enabled = True
Me.tblAllocation_subform.Locked = False
Me.Command80.Enabled = True
End If
Select Case OS
Case "Confirmed"
Me.cmdPDF_NoCosts.Visible = True
Me.cmdPDF_Costs.Visible = True
Case "New"
Me.cmdPDF_NoCosts.Visible = False
Me.cmdPDF_Costs.Visible = False
End Select
Select Case UT
Case "Admin"
If OrderStatus = "Confirmed" Then
Me.cmdFinancePDF.Visible = True
Else
Me.cmdFinancePDF.Visible = False
End If
Case "Director"
If OrderStatus = "Confirmed" Then
Me.cmdFinancePDF.Visible = True
Else
Me.cmdFinancePDF.Visible = False
End If
If Me.txtLogDate <> Date Then
Me.AllowEdits = False
Me.[tblAllocation subform].Locked = True
Me.FinanceNotes.Enabled = False
Me.ProductionNotes.Enabled = False
Me.OrderDetail.Enabled = False
Me.Command52.Enabled = False
Me.Command53.Enabled = False
Me.Command104.Enabled = False
Me.Command110.Enabled = False
Me.cmdPDF_Costs.Enabled = False
Me.cmdFinancePDF.Enabled = False
Me.cmdPDF_NoCosts.Enabled = False
Else
Me.AllowEdits = True
Me.[tblAllocation subform].Locked = False
Me.FinanceNotes.Enabled = True
Me.ProductionNotes.Enabled = True
Me.OrderDetail.Enabled = True
Me.Command52.Enabled = True
Me.Command53.Enabled = True
Me.Command104.Enabled = True
Me.Command110.Enabled = True
Me.cmdPDF_Costs.Enabled = True
Me.cmdFinancePDF.Enabled = True
Me.cmdPDF_NoCosts.Enabled = True
End If
Case "User"
If Me.txtLogDate <> Date Then
Me.AllowEdits = False
Me.[tblAllocation subform].Locked = True
Me.FinanceNotes.Enabled = False
Me.ProductionNotes.Enabled = False
Me.OrderDetail.Enabled = False
Me.Command52.Enabled = False
Me.Command53.Enabled = False
Me.Command104.Enabled = False
Me.Command110.Enabled = False
Me.cmdPDF_Costs.Enabled = False
Me.cmdFinancePDF.Enabled = False
Me.cmdPDF_NoCosts.Enabled = False
Else
Me.AllowEdits = True
Me.[tblAllocation subform].Locked = False
Me.FinanceNotes.Enabled = True
Me.ProductionNotes.Enabled = True
Me.OrderDetail.Enabled = True
Me.Command52.Enabled = True
Me.Command53.Enabled = True
Me.Command104.Enabled = True
Me.Command110.Enabled = True
Me.cmdPDF_Costs.Enabled = True
Me.cmdFinancePDF.Enabled = True
Me.cmdPDF_NoCosts.Enabled = True
End If
Case "Manager+"
If Me.txtLogDate <> Date Then
Me.AllowEdits = False
Me.[tblAllocation subform].Locked = True
Me.FinanceNotes.Enabled = False
Me.ProductionNotes.Enabled = False
Me.OrderDetail.Enabled = False
Me.Command52.Enabled = False
Me.Command53.Enabled = False
Me.Command104.Enabled = False
Me.Command110.Enabled = False
Me.cmdPDF_Costs.Enabled = False
Me.cmdFinancePDF.Enabled = False
Me.cmdPDF_NoCosts.Enabled = False
Else
Me.AllowEdits = True
Me.[tblAllocation subform].Locked = False
Me.FinanceNotes.Enabled = True
Me.ProductionNotes.Enabled = True
Me.OrderDetail.Enabled = True
Me.Command52.Enabled = True
Me.Command53.Enabled = True
Me.Command104.Enabled = True
Me.Command110.Enabled = True
Me.cmdPDF_Costs.Enabled = True
Me.cmdFinancePDF.Enabled = True
Me.cmdPDF_NoCosts.Enabled = True
End If
Case "Finance"
If OrderStatus = "Confirmed" Then
Me.cmdFinancePDF.Visible = True
Else
Me.cmdFinancePDF.Visible = False
End If
End Select
If Me.Text123 = 0 Then
Me.Text125.Visible = False
Else
Me.Text125.Visible = True
End If
[B] If Me.Net = 0 Then
Me.Command80.Visible = False
Else
If Me.Net = Forms!orderentry![tblAllocation subform].Form.Text9 Then
Me.Command80.Visible = True
Else
Me.Command80.Visible = False
End If
End If[/B]
MsgBox "Main Form/Form Current has Fired!"
I've made the part that refers to the Proceed button bold, but thought I'd add in the whole OnCurrent event in case there was anything in there that was blocking it.
I added in the MsgBox code at the bottom to make sure the OnCurrent was firing, and that works fine.
I've searched through the rest of the code, and there's nothing else in there that references the Visible property of the button.
I've been through the decompile process detailed here, and also been through this similar thread with a fine toothcomb and this still won't work.
I've saved the form out as a textfile and then imported it back in, both through the immediate window, and short of importing everything in to a new DB and starting again, I'm actually pretty stumped!!
So any help will be most appreciated, thanks!