Link to home
Start Free TrialLog in
Avatar of jaisonshereen
jaisonshereen

asked on

3021:no current record

when i select some data in drop down box for creating a report and click the create report button . I am getting the error "3021:no current record"

but some time not... please help me !!

Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

post the codes in the click event of the button
Avatar of jaisonshereen
jaisonshereen

ASKER

This is the code for click button :


Private Sub Cmd_rief_Click()
On Error GoTo Err_Cmd_rief_Click
 
    Call Project1.Form_T_GeneralSearch.CheckForNullSearch
    
    FixSearchCriteria
    
    DoCmd.OpenReport "T_riefReport", acViewPreview
 
Exit_Cmd_rief_Click:
    Exit Sub
 
Err_Cmd_rief_Click:
    ApplicationError Err.Number, Err.Description, "Form_T_ViewRollupPromotions\Cmd_rief_Click"
    Resume Exit_Cmd_rief_Click
 
End Sub

Open in new window


Public Sub FixSearchCriteria()
On Error GoTo Err_FixSearchCriteria
 
    CurrentProject.Connection.Execute "DELETE * FROM T_TempSearch"
    
    DoCmd.SetWarnings False
    DoCmd.RunSQL "DELETE * FROM T_TempSearch"
    DoCmd.OpenQuery "T_SearchFixSearchCriteriaFix"
       
Exit_FixSearchCriteria:
    Exit Sub
 
Err_FixSearchCriteria:
    ApplicationError Err.Number, Err.Description, "Module1\FixSearchCriteria"
    Resume Exit_FixSearchCriteria
    
End Sub

Open in new window


Public Sub CheckForNullSearch()
On Error GoTo Err_CheckForNullSearch
    
    'Checks general search form for any nulls
    'Dirty = False
    
    If IsNull(Me.Combo_Year) Or Me.Combo_Year = "0" Or Me.Combo_Year = "" Then Me.Combo_Year = "Year"
    If IsNull(Me.Combo_TempPromoID) Or Me.Combo_TempPromoID = "" Then Me.Combo_TempPromoID = "0"
    If IsNull(Me.Combo_EnteredBy) Or Me.Combo_EnteredBy = "0" Or Me.Combo_EnteredBy = "" Then Me.Combo_EnteredBy = "Log on"
    If IsNull(Me.Combo_PromoPeriod) Or Me.Combo_PromoPeriod = "0" Or Me.Combo_PromoPeriod = "" Then Me.Combo_PromoPeriod = "Period"
    If IsNull(Me.Combo_Location) Or Me.Combo_Location = "" Or Me.Combo_Location = "" Then Me.Combo_Location = "Location"
    If IsNull(Me.Combo_CategoryMan) Or Me.Combo_CategoryMan = "0" Or Me.Combo_CategoryMan = "" Then Me.Combo_CategoryMan = "Category Manager"
    If IsNull(Me.Combo_CatID) Or Me.Combo_CatID = "" Then Me.Combo_CatID = "0"
    If IsNull(Me.Combo_StartDate) Or Me.Combo_StartDate = "" Or Me.Combo_StartDate = "0" Then Me.Combo_StartDate = "Start Date"
    If IsNull(Me.Combo_Status) Or Me.Combo_Status = "" Or Me.Combo_Status = "0" Then Me.Combo_Status = "Status"
    If IsNull(Me.Combo_article) Or Me.Combo_article = "" Or Me.Combo_article = "0" Then Me.Combo_article = "0"
    
    'Dirty = False
    
Exit_CheckForNullSearch:
    Exit Sub
 
Err_CheckForNullSearch:
    
    'Entered an item not in the list
    If Err.Number = 2237 Then Resume Next
    
    'If a Null value after the dirty=false then error will occur
    If Err.Number = 3058 Then Resume Next
                        
    'No current record
    If Err.Number = 3021 Then Resume Next
                        
    ApplicationError Err.Number, Err.Description, "T_F900_GeneralSearch\CheckForNullSearch"
    Resume Exit_CheckForNullSearch
    
End Sub

Open in new window

let me know any other code u want of any functions above!
u want the query "  DoCmd.OpenQuery "T_SearchFixSearchCriteriaFix""?

comment the same lines like the one posted below

now select the same value from the combo that gives error and click the button

see if you will still get the error. post here the result
Private Sub Cmd_rief_Click()
On Error GoTo Err_Cmd_rief_Click
 
 '   Call Project1.Form_T_GeneralSearch.CheckForNullSearch
    
 '   FixSearchCriteria
    
    DoCmd.OpenReport "T_riefReport", acViewPreview
 
Exit_Cmd_rief_Click:
    Exit Sub
 
Err_Cmd_rief_Click:
    ApplicationError Err.Number, Err.Description, "Form_T_ViewRollupPromotions\Cmd_rief_Click"
    Resume Exit_Cmd_rief_Click
 
End Sub

Open in new window

yes its worked !!! thanks a lot

can u tell what was wrong inside the "CheckForNullSearch"

so that i can debug inside the function  and un comment it to work ?
not yet we commented two lines.

now uncomment the first one and try again

   Call Project1.Form_T_GeneralSearch.CheckForNullSearch
oops ..last time i did the same

i commented only "Call Project1.Form_T_GeneralSearch.CheckForNullSearch"

it was working fine ... !!

do i need to comment "'   FixSearchCriteria" and check again?
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks dude ... thanks a million ton !!

Cheers !!