472,787 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Populate a continuous form using ADO

Hi there, I am trying to populate a continuous form using ADO, following is
the function which needs fixing, can someone kindly help me with this.
Thanks much

Private Sub Form_Load()

On Error GoTo err_Form_Load
Dim objRstADO As ADODB.Recordset
Dim sqlstr As String
Dim tZone As String

If PostgreSQLADOConnection() Then

tZone = "set timezone to 'GMT'; set datestyle to 'ISO'; " & _
"select version(), case when pg_encoding_to_char(1) =
'SQL_ASCII' " & _
"then 'UNKNOWN' else getdatabaseencoding() end"
cPostgreSQL.Execute tZone

sqlstr = "Select a.id, a.name, count(*) as count " & _
"FROM tblcustomer a, tblorder b " & _
"WHERE a.order_id=b.id " & _
"GROUP BY 1,2 " & _
"ORDER BY 3 DESC"
Set objRstADO = cPostgreSQL.Execute(sqlstr, , adLockReadOnly)

Set Me.Recordset = objRstADO

Do While Not objRstADO.EOF

objRstADO.MoveNext
Me.txtID = objRstADO("id")
Me.txtName = objRstADO("name")
Me.txtCount = objRstADO("count")
Loop

objRstADO.Close
Set objRstADO = Nothing

Else
MsgBox "Connection error: Could not execute"
End If
Exit Sub

err_Form_Load:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly
End Sub

Nov 12 '05 #1
1 2873
For one thing, you shouldn't need the loop at the end populating your
controls.
Setting the Recordset property of your form should be sufficient.

Also, you haven't specified what behavior you're getting here, so I don't
know exactly what you want but aren't getting.
But I would be very surprised if this SQL returned a recordset which was
updatable.

HTH
- Turtle

"tmuhammad" <tm*******@rogers.com> wrote in message
news:MY********************@news04.bloor.is.net.ca ble.rogers.com...
Hi there, I am trying to populate a continuous form using ADO, following is the function which needs fixing, can someone kindly help me with this.
Thanks much

Private Sub Form_Load()

On Error GoTo err_Form_Load
Dim objRstADO As ADODB.Recordset
Dim sqlstr As String
Dim tZone As String

If PostgreSQLADOConnection() Then

tZone = "set timezone to 'GMT'; set datestyle to 'ISO'; " & _
"select version(), case when pg_encoding_to_char(1) =
'SQL_ASCII' " & _
"then 'UNKNOWN' else getdatabaseencoding() end"
cPostgreSQL.Execute tZone

sqlstr = "Select a.id, a.name, count(*) as count " & _
"FROM tblcustomer a, tblorder b " & _
"WHERE a.order_id=b.id " & _
"GROUP BY 1,2 " & _
"ORDER BY 3 DESC"
Set objRstADO = cPostgreSQL.Execute(sqlstr, , adLockReadOnly)

Set Me.Recordset = objRstADO

Do While Not objRstADO.EOF

objRstADO.MoveNext
Me.txtID = objRstADO("id")
Me.txtName = objRstADO("name")
Me.txtCount = objRstADO("count")
Loop

objRstADO.Close
Set objRstADO = Nothing

Else
MsgBox "Connection error: Could not execute"
End If
Exit Sub

err_Form_Load:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly
End Sub

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Prakash Wadhwani | last post by:
Is there any EASY way to highlight a full row in a continuous form so that as i navigate up & down the table/continuous form using the arrow keys, the entire line (all fields) get highlighted ? ...
3
by: Damian | last post by:
Hi. Is there a way to programatically populate a continuous form? I have an array of descriptions that I want to display in the continuous form and I have a textbox on the form called...
3
by: Mark | last post by:
Hi there, I have a subform, set as a continuous form. When a user selects a particular record in that subform, how can I make that particular record stand out (color or font change, size, etc) from...
3
by: David | last post by:
Hi, I need a button shown for each record (cont. form) with specific captions on each. I have a notes form for each record. When a user presses the button they can read the notes. I want to...
3
by: Richard Hollenbeck | last post by:
I have the following query in my form's code: Private Function Get_Data(fieldNum As Integer) Dim strSQL As String Dim db As DAO.Database Dim rs As DAO.Recordset strSQL = "SELECT & "", "" & ...
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
1
by: monsey11 | last post by:
Hi all, I'm racking my brain to come with an idea for a form. here are the requirements: its for a custom quilt manufacturer and on each quilt order there may be added many customizable...
5
by: Desmond Shek | last post by:
Hi, I am new to this DB caper and am really struggling. I have a form called customers with a subform called property search. The subform (a continuous form) allows users to search the table...
13
by: eighthman11 | last post by:
using Access 2003 and sql server version 8.0 Hey everyone. Created a text box where the user types in an Inventory number and it takes them to that inventory number on the contimuous form. The...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.