473,396 Members | 1,765 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,396 software developers and data experts.

How do I text field auto refresh?

beldom
10
I've put together this code from bits and pieces I've found online, am beginner at VBA.
My inquiry is this: How do I make the input field this button is connected to automatically refresh after it's been used to input the selection, which is displayed in listbox 149?
I'm having the string from Where clause be displayed in another text field (how it was in the sample I code I got online), and the listbox shows patient's first name, last name and gender.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearch_Click()
  2.     On Error Resume Next
  3.     Dim ctl As Control
  4.     Dim sSQL As String
  5.     Dim sWhereClause As String
  6. Dim db As DAO.Database
  7. Dim rs As DAO.Recordset
  8. 'Dim strSQL As String
  9. Set db = CurrentDb
  10.     'Initialize the Where Clause variable.
  11.     sWhereClause = " Where "
  12.     'Start the first part of the select statement.
  13.     sSQL = "select * from Patients "
  14.     'sSQL = "INSERT INTO Patients (MedRec,Gender) VALUES (1121, 'R');"
  15.  
  16.     'Loop through each control on the form to get its value.
  17.     For Each ctl In Me.Controls
  18.         With ctl
  19.             'The only Control you are using is the text box. However, you can add as many types of controls as you want.
  20.             Select Case .ControlType
  21.                 Case acTextBox
  22.                     .SetFocus
  23.                     'This is the function that actually builds the clause.
  24.                     If sWhereClause = " Where " Then
  25.                         sWhereClause = sWhereClause & BuildCriteria(.Name, dbText, .Text)
  26.                     Else
  27.                         sWhereClause = sWhereClause & " and " & BuildCriteria(.Name, dbText, .Text)
  28.                     End If
  29.             End Select
  30.         End With
  31.     Next ctl
  32.     'Set the forms recordsource equal to the new select statement.
  33.     Me.txtSQL = sSQL & sWhereClause & ";"
  34.     'Me.RecordSource = sSQL & sWhereClause & ";"    'Me.Query = sSQL & sWhereClause   'Me.Requery
  35.     'db.Execute sSQL & sWhereClause & ";", dbFailOnError
  36.  
  37. 'Me.List149.RowSource = db.OpenRecordset("select * from Patients;")
  38. Set rs = db.OpenRecordset(sSQL & sWhereClause & ";")
  39.  
  40.     'Do While Not rs.EOF
  41.     '    Me.List149.AddItem (rs![First Name] & ";" & rs![Last Name])
  42.     '    rs.MoveNext
  43.     'Loop
  44.  
  45.                 'Dim db As DAO.Database
  46.                 'Dim rs As DAO.Recordset
  47.                 Dim lst As ListBox
  48.                 'strBuild = ""
  49.  
  50.                 Set lst = Me![List149]
  51.  
  52.                 'Set up the Listbox correctly, if it isn't already
  53.                 lst.RowSourceType = "Value List"
  54.                 lst.ColumnCount = 3
  55.                 lst.BoundColumn = 3     
  56.                 lst.ColumnWidths = "1 in;1 in;1 in" 
  57.  
  58.                 'Set db = CurrentDb
  59.  
  60.                 'Set rs = db.OpenRecordset("SELECT * FROM AnswerT WHERE QuestionID =" & QuestionID)
  61.  
  62.                 Do While Not rs.EOF
  63.  
  64.                     strBuild = strBuild & rs!Gender & ";" & rs![Last Name] & ";" & rs![First Name] & ";"
  65.                      rs.MoveNext
  66.                 Loop
  67.  
  68.                 lst.RowSource = Left$(strBuild, Len(strBuild) - 1)
  69.  
  70.  
  71.  
  72.  
  73.  
  74. rs.Close
  75. Set rs = Nothing
  76.     Set db = Nothing
  77.     End Sub
Jul 21 '14 #1
1 1252
beldom
10
I've entered

me.requery
me.refresh
End Sub

seems to have fixed the issue.
Jul 21 '14 #2

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

Similar topics

1
by: Lew | last post by:
Hi all, I'm trying to create a page that has a user-selectable page auto-refresh option (IE 5.5). Essentially, it's a page that contains a checkbox, when the user checks the checkbox, I'd like...
4
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT...
7
by: Brian | last post by:
hello, I am looking for a way to auto refresh a web page that I created, but also let the user choose to stop the auto refresh. I can not figure out how to stop the auto refresh. Any help would...
3
by: JaRudzik | last post by:
Hello Try to add some blank text field and refresh window in IE it is ok but in firefox input hide_show works wrong , why ? Somebody can help me ? I'm not good in JS beacause I'm PHP coder ...
3
by: lezzo | last post by:
Hi Guys, I am new to this forum and find very interesting. I need your help in one of the script. I got a MySQL table bid_amount, and i want that if some new data comes in this table and...
1
by: BibhuAshish | last post by:
hi, I have designed a jsp page. This jsp is able to auto refresh after 5 second. But i want after 5th times of auto refreshment the table present inside the body should change. Can anybody...
2
by: =?Utf-8?B?QW1pciBUb2hpZGk=?= | last post by:
Hi I have a web page that has a TreeView on it. If I DONT'T expand the TreeView nodes, the auto refresh works nicely: my page gets refreshed every minute. As soon as I expand a node on the...
6
by: Peter | last post by:
I have a APS.NET 3.5 webpage which calls a web service. What I need is to update this page automatically when a value changes in the webservice, does anyone have an example? Thank You ...
1
DebadattaMishra
by: DebadattaMishra | last post by:
Introduction In case of rich applications, you must have observed that a text field behaves like a dynamic combo box. When the user enters some characters in the text field, a popup will come up...
3
by: tvnaidu | last post by:
How to auto refresh page for every 3 minutes by passing command part of URL?. I need to refresh one page automatically by passing that refresh command part of url, for example if I want to refresh...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.