By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,434 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

Refresh Detail in Access

P: 46
The following code is not displaying the data that this statement is selecting on the Access Form. What's wrong with it? Thanks in advance.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cbxEvaluatee_AfterUpdate()
  2. sqltext = " select dbo.idtoname(i.eid)as evaluator, dbo.idtoname(i.evalteeid) as evaluatee,* from viewt120 v , evalissue i " & _
  3.      " where v.evalrecno = I.RecNo " & _
  4.     " and formno = 'T120'" & _
  5.     " and evalteeid = " & Me.cbxEvaluatee
  6. Debug.Print sqltext
  7.     Me.Refresh
  8.     Me.Detail.Visible = True
  9. End Sub
Feb 26 '08 #1
Share this Question
Share on Google+
5 Replies


Delerna
Expert 100+
P: 1,134
Where are you actualy executing the query?
and how are you connecting it to the form?
Feb 26 '08 #2

missinglinq
Expert 2.5K+
P: 3,532
As Delerna has intimated, your code doesn't actually run your SQL statement. In point of fact you cannot run SQL SELECT statements from code in Access, only Action statements, such as APPEND, DELETE, UPDATE, etc. Where/how would Access display the results? To do this from VBA you'd have to run a stored parameter query, providing the required Evaluatee parameter.

Linq ;0)>
Feb 27 '08 #3

Delerna
Expert 100+
P: 1,134
Tenesh, you could say
Expand|Select|Wrap|Line Numbers
  1. Private Sub cbxEvaluatee_AfterUpdate()
  2. sqltext = " select dbo.idtoname(i.eid)as evaluator, dbo.idtoname(i.evalteeid) as evaluatee,* from viewt120 v , evalissue i " & _
  3. " where v.evalrecno = I.RecNo " & _
  4. " and formno = 'T120'" & _
  5. " and evalteeid = " & Me.cbxEvaluatee
  6.  
  7. me.RecordSource=sqltext
  8.  
  9. Me.Refresh
  10. Me.Detail.Visible = True
  11. End Sub
  12.  
  13.  
to execute the select query on you form. I have bolded the change I made.

Of course the form would need to be able to handle the recordset returned. IE textboxes with their datasources set correctly etc.
Feb 27 '08 #4

P: 46
Where are you actualy executing the query?
and how are you connecting it to the form?

I was missing the:
me.RecordSource=sqltext,
I didn't realize it was required.
Feb 27 '08 #5

NeoPa
Expert Mod 15k+
P: 31,769
If items have beed added or removed from the underlying recordset then line #9 (Delerna's code) should be replaced by :
Expand|Select|Wrap|Line Numbers
  1. Me.Requery
Feb 28 '08 #6

Post your reply

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