473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error: No Current Record

I'm running into a problem with running multiple queries. I have two tables that look like:

Risk_Mgmt_Table
Fields: (Values)
Filing_State: (CA)
Membership: (Yes)
Membership_Rate: (.95)
Filing_State: (CA)
Membership: (No)
Membership_Rate: (1)

When I run the query, I get the error "No Current Record" when "No" is selected from a combo box. My code is:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Compare Database
  3. Dim ADA_Member_Factor As Double
  4. Dim Risk_Mgmt_Factor As Double
  5. Private Sub Calc_Final_Rate_Btn_Click()
  6. On Error GoTo Err_Calc_Final_Rate_Btn_Click
  7.  
  8.     Call Run_ADA_Qry
  9.     Call Run_RiskMgmt_Qry
  10.  
  11.     Dim stDocName As String
  12.     stDocName = "Final_Rate_Form"
  13.     DoCmd.OpenForm stDocName, , , stLinkCriteria, , , ADA_Member_Factor
  14.  
  15. Exit_Calc_Final_Rate_Btn_Click:
  16.     Exit Sub
  17.  
  18. Err_Calc_Final_Rate_Btn_Click:
  19.     MsgBox Err.Description
  20.     Resume Exit_Calc_Final_Rate_Btn_Click
  21.  
  22. End Sub
  23. Sub Run_ADA_Qry()
  24.  
  25.     Dim db As Database
  26.     Dim ws As Workspace
  27.     Dim ADA_Member As Recordset
  28.     Dim sql As String
  29.  
  30.     Set ws = DBEngine.Workspaces(0)
  31.     Set db = ws.Databases(0)
  32.  
  33.     sql = "SELECT Membership_Credit_Table.FILING_STATE, Membership_Credit_Table.Membership, Membership_Credit_Table.Membership_Rate FROM Membership_Credit_Table WHERE (((Membership_Credit_Table.FILING_STATE)='" & [Forms]![Credit_Debit_OCC_Form]![Filing_State] & "' ) AND ((Membership_Credit_Table.Membership)=" & [Forms]![Credit_Debit_OCC_Form]![OCC_ADA_Combo] & "));"
  34.     Set ADA_Member = db.OpenRecordset(sql)
  35.     ADA_Member_Factor = ADA_Member!Membership_Rate
  36.  
  37.     MsgBox ADA_Member_Factor, vbOKOnly, "Test text ADA Member"
  38.  
  39. End Sub
  40. Sub Run_RiskMgmt_Qry()
  41.  
  42.     Dim db As Database
  43.     Dim ws As Workspace
  44.     Dim Risk_Member As Recordset
  45.     Dim sql As String
  46.  
  47.     Set ws = DBEngine.Workspaces(0)
  48.     Set db = ws.Databases(0)
  49.  
  50.     sql = "SELECT Risk_Mgmt_Table.FILING_STATE, Risk_Mgmt_Table.Membership, Risk_Mgmt_Table.Membership_Rate FROM Risk_Mgmt_Table WHERE (((Risk_Mgmt_Table.FILING_STATE)='" & [Forms]![Credit_Debit_OCC_Form]![Filing_State] & "' ) AND ((Risk_Mgmt_Table.Membership)=" & [Forms]![Credit_Debit_OCC_Form]![OCC_RiskMgmt_Combo] & "));"
  51.     Set Risk_Member = db.OpenRecordset(sql)
  52.     Risk_Mgmt_Factor = Risk_Member!Membership_Rate
  53.  
  54.     MsgBox Risk_Mgmt_Factor, vbOKOnly, "Test text Risk Management"
  55.  
  56. End Sub
  57.  
I'm running two queries that against tables that are almost exactly the same. The combo boxes are in a form named: Final_Rate_Form

It works perfectly when the combo boxes are set to "Yes", so I'm not sure what's going on.?.? Any info is appreciated!!!
Aug 26 '10 #1
5 2837
NeoPa
32,556 Expert Mod 16PB
How about popping the actual SQL in here just as it is before it's executed in lines #34 and #51.

Trying to determine what it is likely to be from your code when most of the relevant information is not there is more trouble than it need be.
Aug 26 '10 #2
Here's the SQL lines:



sql = "SELECT Membership_Credit_Table.FILING_STATE, Membership_Credit_Table.Membership, Membership_Credit_Table.Membership_Rate FROM Membership_Credit_Table WHERE (((Membership_Credit_Table.FILING_STATE)='" & [Forms]![Credit_Debit_OCC_Form]![Filing_State] & "' ) AND ((Membership_Credit_Table.Membership)=" & [Forms]![Credit_Debit_OCC_Form]![OCC_ADA_Combo] & "));"
Aug 26 '10 #3
colintis
255 100+
have you tried the code in a query? with some variables replacing the form values for test purposes. Like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT Membership_Credit_Table.FILING_STATE
  2. , Membership_Credit_Table.Membership
  3. , Membership_Credit_Table.Membership_Rate 
  4. FROM Membership_Credit_Table 
  5. WHERE (((Membership_Credit_Table.FILING_STATE)='CA' ) 
  6. AND ((Membership_Credit_Table.Membership)=No));
Aug 27 '10 #4
NeoPa
32,556 Expert Mod 16PB
Jamen98:
Here's the SQL lines:
You've misunderstood what I posted. I thought I must have said it wrong, but I checked and no - I didn't.

Please post the SQL. That is the contents of the string sql and not the VBA code that creates the string.

When you do, make sure you post it in the [ CODE ] tags provided (which are mandatory).
Aug 27 '10 #5
Figured it out... Stupid quotes!!! I was missing the ' on the second query criteria... Thanks colintis, that was a helpful troubleshooting technique. I'm a newby (I'm sure it's obvious) at VBA...

Thanks!
Aug 27 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tony | last post by:
Hello, I am having difficulty in getting the current record of the current form to show after pressing a command button that takes me to another form. The command button takes me to another...
1
by: Colin Graham | last post by:
I am writing this piece of code to show the previous record on a control on the form but i keep getting the error message "Error 3021 no current record " and the line marked *** gets highlighted. I...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
3
by: hebandgene | last post by:
When I delete a record in a subform I get the warning that I'm about to delete a record, followed by an error "No current record." When I click OK obviously the record is deleted and it goes to...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: 4004 | last post by:
I would like to open a columnar form (so I can see all the details) from a datasheet form (so I can see what is there) but keep the same recordset and current record. I can do the recordset set...
5
by: eighthman11 | last post by:
Hi everyone: This is probably a pretty simple problem but it is driving me nuts. Using Access 2000. I have a continuous form which list several thousand inventory items. The user can enter a...
2
by: Tom Clavel | last post by:
Scratching my head. I am using the filter property on a combo box .AfterUpdate event to get to a single client record. This is causing a some strange behavior: As I enter a subform, I get a no...
3
by: Kosmos | last post by:
Hey ya'll...I can't seem to figure out why I'm getting this error message, but it all started when I added the new line of code with the recSet5.AddNew --- when I ran the first line, the logic worked...
2
by: Ian | last post by:
I am trying to save the current record on a form before opening a report, doesn’t sound to hard does it? The code on a buttons on click event goes like this: DoCmd.DoMenuItem acFormBar,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.