Post the database or post the exact error message....were at post #68.....In the Main form i have got the result it's working but in sub form it's generate error.
=IIf(IsNull([AdjustmentSub].[Form]![ItemsFK]),Null,DSum("[Stock_In_Out]","TransactionsExtended","[ItemPK]=" & [AdjustmentSub].[Form]![ItemsFK] & "And [TranDate]<= #" & [Forms]![Adjustment].[Form]![TranDate] & "#"))
use this code in your search button.kindly suggest why the filter is not showing results properly.
use this code in your search button.
Option Compare Database
'Option Explicit << remove this
Private Sub Search_Button_Click()
Dim strFilter As String
Dim strDateStart As String
Dim strDateEnd As String
If IsNull(Forms![test].FromDate) Or Forms![test].ToDate = "" Then
MsgBox "Start Date and End Date Required", vbCritical + vbOKOnly + vbDefaultButton1, "Missing Data"
Forms![test].FromDate.SetFocus
Cancel = True
Else
strDateStart = "#" & Format(Forms![test]![FromDate], "mm-dd-yyyy") & "#"
strDateEnd = "#" & Format(Forms![test]![ToDate], "mm-dd-yyyy") & "#"
strFilter = "TranDate Between " & strDateStart & " And " & strDateEnd
Me.Filter = strFilter
Me.FilterOn = True
End If
End Sub
'Option Explicit << remove this
thank you for that concern. I'm just intermediate in VBA...You should always have this at the top of every code module.
It will help highlight at least 25% of the errors new users experience.
Removing it is very poor advice.
Put Option Explicit back though.Thanks Kamayo ...
Thanks Kamayo ...
I knew you are expert sir. But possible sir you can check the attachment . If i put back the "Option explicit" the sorting has an error when i remove its working . I need your help on how to avoid that error even with Option Explicit declared.Put Option Explicit back though.![]()
If Not IsDate(Me.FromDate) Or Not IsDate(Me.ToDate) Then
MsgBox "Start Date and End Date Required", vbCritical + vbOKOnly + vbDefaultButton1, "Missing Data"
Forms![test].FromDate.SetFocus
THANK YOU SO MUCH SIRRE testver2rev1.accdb
I would recommend
-use Option Explicit as second row in all modules
-adjust the date checking/validation
-dim Dates as DateCode:If Not IsDate(Me.FromDate) Or Not IsDate(Me.ToDate) Then MsgBox "Start Date and End Date Required", vbCritical + vbOKOnly + vbDefaultButton1, "Missing Data" Forms![test].FromDate.SetFocus
You are misusing Cancel = True. That is an option on some events. Perhaps I am missing your intent.
Dear Experts,
I have made a QOH value in inventory adjustment form (dlookup function) to see how much QOH for inventory adjustment.
But the issue is that QOH is dynamically changing as the QOH gets changed.
How to make static as the record saved?
kindly correct the formula for the reference of date in sub form.
=IIf(IsNull([AdjustmentSub].[Form]![ItemsFK]),Null,DSum("[Stock_In_Out]","TransactionsExtended","[ItemPK]=" & [AdjustmentSub].[Form]![ItemsFK] & "And [TranDate]<= #" & [Forms]![Adjustment].[Form]![TranDate] & "#"))
HeadFormName: Adjustment
SubformName: AdjustmentSub
DataReferenceQuery: TransactionsExtended