Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Visual Basic





See Related Forum Messages: Follow the Links Below to View Complete Thread

Problem With Setting My ADODC Recordsource
Hi! I tried using these line of codes to set the recordsource of my adodc
control

strSQL = "SELECT sn, rnk1, eca1, cd1 " _
& " FROM eca1 " _
& " WHERE rnk1 =" _
& "'" & CStr(sn1) & "'" _
& " ORDER BY rnk1"

but i encountered this error

"Data type mismatch in criteria expression"

my program is running well when i remove lines 3 and 4.

Can u help me?

Setting The RecordSource For An ADODC With Value From Another Form
I have two forms. I would like to pass the value of a text field on one form (frmMemberBrowse.txtMemberID.Text) to another form (frmInvolvement) and use that as the lookup value for the ADODC RecordSource on that form. (SELECT Field1,Field2,blah,blah WHERE MEMBERID = something, certainly not frmMemberBrowse.txtMemberID.Text since it definitely doesn't like that!)

Can anyone help me with syntax or perhaps I am completely missing the boat. Any help is greatly appreciated.

DWM

ADODC: No Recordsource Specified
Several of my forms contain Adodcs, whose recordsource is a SQL statement containing a variable name. the Adodc (and bound datagrid) work fine for all, but whenever i load or unload the project i always get the following msg:
"ADODC: No Recordsource specified, ADO: cmd text was not set for command object"
Is there anything i can do about this? Thank you in advance!

Adodc Recordsource Problem
I'm working with an ADO data control, and set the record source property to the "customer" table. After setting the recordsource of some of my textboxes to ADODC1, I can set the property datafield to an attribute in that table, but at the same time I want to set the fieldname property of another textbox to an attribute from another table in the database, so when I call an update, fields from different tables will be updated. Can someone help me here?

Adodc Recordsource Property
for the first time i am trying to use adodc. i have a flexgrid and a adodc in my form. if i set the recordsource in the built in ado proprerty window it works fine, but i want to use adodc dynamically by setting the recordsource during run time say on command button click or form load. is it possible to do like that?
thanks for ur help

Adodc Recordsource Error
Hi I am trying to change the recordserouce for my database
and my code is always stuck in the SQL, assist please.

Code:
Private Sub Combo1_Change()
Dim SQL As String
Select Case Combo1.Text
Case 1
MsgBox Adodc1.RecordSource
SQL = "SELECT Type, Name, Price From Table1 WHERE Table.Type = 1"
Adodc1.RecordSource = SQL
MsgBox Adodc1.RecordSource
Adodc1.Refresh
If (Adodc1.Recordset.BOF = True And Adodc1.Recordset.EOF = True) Then
MsgBox ("No records meet the criteria.")
End If
Case 2
Adodc1.RecordSource = "SELECT Table.Type, Table1.Name, Table1.price From Table1 WHERE Type = 2"
Adodc1.Refresh
End Select

End Sub

I get error Data type mismatch in createria expression.
Please assist,
Thank you.

EDIT:Sorry I didnt see the database development forum, i'll post there now.

ADODC RecordSource Properties
How do I put up a query for ADODC (ActiveX Data Object Data Control) in its properties, which can accept a Parameter. And how would it ask for the parameter value from the user???

Query: "Select * from tableName where columnName=" & ParameterValue
Please Help........

ADODC Recordsource At Run Time.
I have two grids and two adodc on a form. When the form is loaded, I would like to populate the grid1 with the view created in Sql db. When user double clicks on one of the rows in the grid1 I would like to populate grid2 based on the values on grid1 row double clicked.


I put following code in the double click event of the grid1. But it just gives me blank rows in the grid2 when it is double clicked. I know that the records exists.

Can someone help me out with this??
Private Sub grdDataGrid_DblClick()

On Error GoTo Err_grdDataGrid_DblClick
'Store the ProjectCode, ModeOfPayment, TypeOfPayment when
' a column is selected in global variables
Dim rsProjName As New ADODB.Recordset
Dim strSql As String
strProjectCode = Trim(grdDataGrid.Columns(2).Text)
strModeOfPayment = Trim(grdDataGrid.Columns(4).Text)
strTypeOfPayment = Trim(grdDataGrid.Columns(5).Text)
strBankAcct = Trim(grdDataGrid.Columns(1).Text)

strSql = "SELECT * from tblPayments" _
& " where tblPayments.BankAccount='" & strBankAcct & "'" _
& " and tblPayments.ProjectCode='" & strProjectCode & "'" _
& " and tblPayments.TypeofPayment=' " & strTypeOfPayment & "'" _
& " and tblPayments.ModeOfpayment=' " & strModeOfPayment & "'"

dataCtl2.RecordSource = strSql
dataCtl2.Refresh
grdDataGrid2.ReBind
grdDataGrid2.Refresh





Exit_grdDataGrid_DblClick:
Exit Sub

Err_grdDataGrid_DblClick:
MsgBox Error$ & Err
Resume Exit_grdDataGrid_DblClick
End Sub

VB 6 Using The Sql In The Adodc Recordsource Property
I am trying to use a sql statement in the adodc recordsource property. I need to use a text box as the where clause restriction suchas
SELECT DISTINCT PM_BUS_NUMBER FROM CSL_STD_DEMO_SCHOOL_TN WHERE PM_BUS_NUMBER IS NOT NULL AND PM_BUS_NUMBER <> '' AND PM_BUS_NUMBER = & ' txtBusNumber.text ' & ORDER BY PM_BUS_NUMBER
I have tried several methods using & ' txtBusNumber.text ' & but when you do not start with a ["] then the text box will not give any data because you do not jump out of the statement to get the textbox info. Can you help me with this problem.

ADODC Recordsource Problem
I am using follwing query as recordsource of ADODC but when i am running the program I am getting error " Too Few Parameters "

Please Help!

Also let me know is there any other way to write the query where Date = Text1.Text is put in clause like below

adodc.recordsource = "SELECT DISTINCTROW Master.Id from master where Master.[date] = '" & # & "' & '" & " & "' & Text1.Text & '" & " & "' & '" & # & "' "


Thanks in Advance

SQL Stmt As ADODC RecordSource
This is probably more a Sql question, but I hope you don't mind if I try it here. Absent the LEFT OUTER JOIN, this code works, but when I add the join the following error occurs:

Run time error '-2147467259 (80004005)'
Data provider or other service returned an E_FAIL status.

Any ideas what's wrong? Thanks


private Sub Form_Load()
Dim sSql as string

datPrimaryRS.ConnectionString = "PROVIDER=MSDataShape;Data PROVIDER=MSDASQL;dsn=develop;uid=sa;pwd=;database=productiondb"
sSql = ""
sSql = sSql & "SHAPE {SELECT AgentMaster.AgentID,NameAddress.FirstName "
sSql = sSql & "FROM AgentMaster "
sSql = sSql & "LEFT OUTER JOIN NameAddress "
sSql = sSql & "on AgentMaster.AgentID = NameAddress.AgentID "
sSql = sSql & "WHERE AgentMaster.AgentID &lt;&gt; 0 "
sSql = sSql & "ORDER BY Agent} "

sSql = sSql & "APPEND ({SELECT * FROM AgentCodes ORDER BY Company } "
sSql = sSql & "RELATE agentid to agentid) as rsAgentCodes, "
sSql = sSql & "({SELECT AgentID, [Contact Code], [Contact], [ContactID], [Email], [fax] [Fax Number] FROM AgentContact ORDER BY Contact} "
sSql = sSql & "RELATE AgentID to AgentID) as rsAgentContact "

datPrimaryRS.RecordSource = sSql
datPrimaryRS.Refresh
set grdAgentCodes.DataSource = datPrimaryRS.Recordset("rsAgentCodes").UnderlyingValue
set grdContact.DataSource = datPrimaryRS.Recordset("rsAgentContact").UnderlyingValue

SQL Statement As Recordsource Of ADODC Control
Hi! I tried using these line of codes to set the recordsource of my adodc
control

strSQL = "SELECT sn, rnk1, eca1, cd1 " _
& " FROM eca1 " _
& " WHERE rnk1 =" _
& "'" & CStr(sn1) & "'" _
& " ORDER BY rnk1"

but i encountered this error

"Data type mismatch in criteria expression"

my program is running well when i remove lines 3 and 4.

Can u help me?

Adodc Connectionstring/recordsource Problem
Iíve got a little project that displays data on a DataGrid. (I think that the whole thing was copied from a MS example in the first place although I canít find the source nowÖ) The DataSource (of the DataGrid) is an adodc control. How do I change the adodcís connectionstring and recordsource at runtime?
Is it even possible?
This question seems to have been asked before but without any meaningful (to me) resolution. Any offers?

TIA

Dave

ADODC Recordsource Property Prob
Can somebody please tell me how to query my ORACLE tables by selecting the current date on the table and placing the script to the recordsource property of my ADODC..recordsource doesn't recognize a function like sysdate....was trying this script...
select * from orders where date = sysdate
but it doesn't work. pls help.

How Do I Pass An Integer In The Sql Stmt Of Adodc RecordSource?
I am working with an Adodc in VB with Access as the Back End.  There is an ODBC Driver called "BranchErrors".  

Here are the settings on the adodc1.property page:

CommandType = 8 - adCmdUnknown
ConnectionString = DSN=BranchErrors
CursorLocations = 3 - adUseClient
CursorType = 2 - adOpenDynamic
RecordSource = **This is where I need help

When I set the Adodc1.RecordSource property with SQL, how do I pass a long integer in the sql statement.   If I replace the lngTrayID with a number in the sql statement, all is good - but I need to pass it as a variable.  How do I pass a variable containing a number.  

On the property page for the adodc I've tried the following sql statments in the RecordSource property:

1)
SELECT * FROM tblDocPrep_BatchScan
WHERE tblDocPrep_BatchScan.IsRecActive = 'Yes' AND tblDocPrep_BatchScan.TrayID = & lngTrayID ORDER BY tblDocPrep_BatchScan.Time;

and get the following Error Message:
[Microsoft][ODBC Microsoft Access Driver] Syntax Error (missing operator) in query expression 'tblDocPrep_BatchScan.IsRecActive = 'Yes' AND tblDocPrep_BatchScan.TrayID = & lngTrayID'.

2)
SELECT * FROM tblDocPrep_BatchScan
WHERE tblDocPrep_BatchScan.IsRecActive = 'Yes' AND tblDocPrep_BatchScan.TrayID = & lngTrayID & ORDER BY tblDocPrep_BatchScan.Time;

Error Message:
[Microsoft][ODBC Microsoft Access Driver] Syntax Error (missing operator) in query expression 'tblDocPrep_BatchScan.IsRecActive = 'Yes' AND tblDocPrep_BatchScan.TrayID = & lngTrayID &'.

3)
SELECT * FROM tblDocPrep_BatchScan
WHERE tblDocPrep_BatchScan.IsRecActive = 'Yes' AND tblDocPrep_BatchScan.TrayID = lngTrayID ORDER BY tblDocPrep_BatchScan.Time;

Error Message:
[Microsoft][ODBC Microsoft Access Driver] Too few parameters.  Expected 1.

Maybe I have the other property settings not set correctly?

Thank you to the sql guru,
Michelle




Problem In Comparing 2 Dates In Adodc.recordsource
I have to run a query
 adodc1.recordsource = "select * from RawMat_Stock where S_Date = " & dt & " "
 adodc1.refresh

 S_Date is a field and dt holds system's current date .
 There is a record in the table RawMat_Stock which has the S_Date = dt . But the recordset does not fetch that record . recordset.recordcount = 0 returns.

I want that if record exist than ignore otherwise add the record for that date.

So pls help me to run it.

 

Edited by - dilip347 on 1/22/2004 11:25:35 PM

Probelm In Comparing 2 Date In Adodc.recordsource Query Run
I have Access database file OrderDetail which has DateDeliver as Date type field .
I want all order record for the next 7 days from today .
 But when i use the code below , the recordset.recordcount returns zero though the table contains some records within that date period.

    Adodc1.RecordSource = "select * from OrderDetail where DateDeliver >= '" & Date & "' and DateDeliver <= '" & DateAdd("d", 6, Date) & "' "
    Adodc1.Refresh


Pls help me to solve the problem .




Edited by - dilip347 on 1/24/2004 2:37:00 AM

Setting Report Recordsource
Hi...I have one report that is generated from one of 4 almost identical queries. Therefore, as per whatever conditions i need to set the recordsource to whichever query applies. I have written the below using 2 different tech's for setting it but it does not like. An error comes up saying "the report 'rptChar' is misspelled or does not exist" but it is spelled corrrectlty and does exist. I am thinking it syntax error but any advice would be mucho helpful.

--------------------------------------------------------------------------------
If cbox_Status = "(ALL)" And cbox_Trait = "(ALL)" Then
(I)Reports("rptChar").RecordSource = "qryReport_Chars_none"(/I)
DoCmd.OpenReport "rptChar", A_PREVIEW
End If
If cbox_Status <> "(ALL)" And cbox_Trait = "(ALL)" Then
(I)[Reports]![rptChar].RecordSource = "qryReport_Chars_statusonly"(/I)
DoCmd.OpenReport "rptChar", A_PREVIEW
End If
If cbox_Status = "(ALL)" And cbox_Trait <> "(ALL)" Then
[Reports]![rptChar].RecordSource = "qryReport_Chars_traitonly"
DoCmd.OpenReport "rptChar", A_PREVIEW
End If
If cbox_Status <> "(ALL)" And cbox_Trait <> "(ALL)" Then
[Reports]![rptChar].RecordSource = "qryReport_Chars"
DoCmd.OpenReport "rptChar", A_PREVIEW
End If

Setting Access Report Recordsource To A Filtered Recordset
Hi,

in my Access application on Report_Open of a report.

I do some manipulations to a recordset.
Now i want to be able to update the recordsource of my report with the recordset i just worked on. I get an error type mismatch

me.recordsource = filteredRs

I have tried several other ways. If anyone can please help me.

Retrieving Data From A RecordSource Set By Code
(This thread has also been started in the Database Development forum)

I am opening a report (in Access) and the recordsource of the report is set on the report_open event of the report. This works perfectly. (Report.RecordSource = ("SELECT * ..........")

That query will always return only 1 record.

Here's the problem:
I want (still by code, still in the report_open event and right after the recordsource is set) to be able to read the content of that same record.

Now, I can't refer to a textbox on the report, seems like it is not yet populated? That would explain why I can't use the textbox to retrieve the value. But that makes me think, maybe the recordsource I've set ain't even filled yet... and won't be until the report_open event is DONE ?

If so I'm asking for something impossible.

Thanks for any feedback

Krass

Access 2k SubReport...filtering Recordsource Via Code?
I've got a form that provides the user some options for reporting items from sets of data...
1) Which set of data (select one)
2) Which report (select one)
3) Report on which type of items (multi select)
4) Report on all or just flagged items (check box)

The report in question has a record source that is a query that pulls some common data for all datasets
The report is opened from the code for the report selection form via:
DoCmd.OpenReport cboReport.value, acViewPreview, , "s.DataSetID=" & lstDataSets.Column(0)
This is to pick up only the data for the data set that the user selected... and it seems to be working ok.

Then there is a subreport for the items...
I'm rather new with access reports... so I might be going about this all wrong, BUT...
The SubReport has a recordsource that is a query that pulls item info for all datasets. The SubReport is linked to the main one by the DataSetID... this seems to what is filtering out items that don't belong to the dataset in question.

Problem is implementing the other controls... such as if the user only wants to report on one "type" of item.

Any suggestions on filtering the data in the subreport via code?

Thanks

Setting ADODC Connection Properties
Hi team,

I need to be able to dynamically set an ADO DataControl to the correct DNS.

adodc1.connectionstring = "yada yada" in the form load event does not work. It seems to try to initialise the adodc before it gets to the form load, it then throws an error saying it does not know where to connect. When I hard code a DSN it seems to look for this hard coded value first and if it can't find it it again throws the error. This happens before the form load event.

Any ideas?

FW

Setting Adodc Connectionstring With App.Path
Hello,

I'm trying to set the connectionstring for an Adodc to include App.Path, but no matter how I try things, I can't get it to work. I'm hoping that there is just some syntax that I don't know, or something simple like that. Any help please?

Setting ADODC Password At Runtime?
Hi All

In our project there is ADODC controls all over the place we now need to set the login name and password at runtime for all these controls is there an easy way of achieving this.

We have tried to looping through all the forms and looping through all the controls and setting the password that way, but we have trouble achieving this.

Problem With Setting The Recourdsource Of An ADODC Given A Condition
Im having problems with setting the record source of my ADODC control.
Im using an SQL statement SELECT ec1 from ECA1 where sn = sn1

ec1 and sn are variables in my ECA1 table.
while sn1 is a global variable

Is this possible?

I need your help badly.

Using A Adodc In Code
I know I can do this:

Adodc1.Recordset.AddNew
Adodc1.Recordset("Name") = medName.ClipText
Adodc1.Recordset.Save

The above works fine and saves the info in the database table, but only if there is at least one control on the form bound to a field in Adodc1.

What I would like to know is how to 'activate' the control in code.

I have tried to open
Adodc1.Open same as without open "Object variable or With block variable not set (Error 91)"
How do I "set" the object variable when the object is defined on the form?

This follows on from my previous question about Masked Edit (I am trying to work around that problem and use masked edit) and also use an adodc not SQL. I use and like SQL I just don't want to use it for this example.

ADODC Vs ADO Code
I'm a newbie with databases. In Visual Basic 6 you can run the Data Form Wizard to generate a form that will read your database which in my case is an Access database. They give you a choice between ADO Data Control and ADO Code. What's the difference? Which is better?

Robert



Edited by - Shandy on 5/30/2004 6:44:37 AM

Adodc, By Code
if i try to connect my adodc database by code, i get this error:

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.


this is my code:
adcEmployee.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\__ajclpayrollDB.mdb;Persist Security Info=False"
adcEmployee.Refresh

i placed it on the form_load event of my form..

can anyone help me figure out what's wrong?

Adodc Vs Code
I hope this question comes out right. But I see alot of people hard coding to access databases.
I have typically just used an Adodc control.
Are there benefits/disadvantages in using either?
Brian

 

Add And Set Properties To An ADODC Using Code.
Hi there,
In my program I have drag and drop an ADODC on my form and in my code I set properties for it like this:

With adodc1
.ConnectionString= "DSN=" & strDSN
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.CommandType = adCmdText
.RecordSource = "SELECT * FROM Table_02"
.Refresh
End With

It work perfectly. But what I want to do is add an ADODC to my program in my code. And I have tried this code:
Dim testADODC As Adodc

With testADODC
.ConnectionString= "DSN=" & strDSN
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.CommandType = adCmdText
.RecordSource = "SELECT * FROM Table_02"
.Refresh
End With

But I get an error "Object variable or With block variable not set" when I set properties to testADODC.
Pls show me how set properties to testADODC.
Thanks.

Navigating Through Records (by Code, Not Adodc)
I have a db with multiple entries. On a form activate, it opens a recordset and loads all the values of the first entry into all the textfields on screen. There are also several buttons on the forms for moving next, previous, last, first. How do I code those buttons to work properly and go through the different records, while refreshing the textboxes to hold the info. from the current record being viewed?

I tried just opening the recordset with all entries, then doing either rs.movenext, moveprevious, etc. depending on which case it is, and then setting each textfield to the corresponding field in the db, but this doesn't work correctly...

thanks in advance.

Ummm... ADODC Connection? Do It With Code Or Control?
How would someone suggest that a beginner connect to a database? By configuring the conrol and binding the recordset to the controls, or connect to the database with code?

Code To Be Executed While Clicking Next On Adodc Control
hi

Is there a way to have a certain code executed everytime you click
on the next, previous, first or last in-built buttons for the adodc control.
I am not using separate command buttons.

thanx in advance

rockbold

Do You Have To Use The ADODC Control If You Connect Using Code In The Script??
Used to web progamming.

I have a data grid that connects to a table via the properties rather than by direct connection in the script.

If I use the
Code:

Set db = New ADODB.Connection

On Error GoTo lbl_Error
db.Open "Provider=MSDASQL.1;Extended Properties=""DSN=MS Access-databas;" _
& "DBQ=" & App.Path & "db1.mdb" & ";UID=admin;"""
On Error GoTo 0

Set rs1 = New ADODB.Recordset
On Error GoTo lbl_Error
rs1.Open "Select * from Table1", db
On Error GoTo 0

rs1.MoveFirst
Do
ListView1.ListItems.Add , , rs1.Fields(1)

rs1.MoveNext
Loop While rs1.EOF = False
Exit Sub


Do I need to put the ADODC control on the form too? And if not how do I set the table1 values to a text box so I can scrollthrough the db?
And finally, if I have a second table that is a child of the first
(links by a sequence field) how do I get this to refresh when I move through the primary table in DB??

How Can I Specify An Adodc Object's Connectionstring Without Having To Hard Code It?
I am "upgrading" a program that was written 5 years ago in vb6. I'm converting it from Access to SQL Server and adding an ini file to define the gConnectionString that is used in about 8 forms encompassing 12 adodc objects. I have the program working fine when not using the ini.

What I am trying to do is leave the connectionstring blank in all of the adodc objects and define them at the start of my application. This seems to work, but in fact it is pulling from my local server instead of the network server. It always pulls locally.

I have left all blank on the adodc objects with the exception of the provider, database name (no server name), and the authentication. All of this is required to run. The server name is defined when the application starts, but even when I define in the very first form that I want a particular server it chooses the local one instead. I have also tried defining the gConnectionString in the Form Load event of each form containing an adodc object.

How can I specify an adodc object's connectionstring without having to hard code it?

What Is The Gen. Code Of Use Connection String Of ADODC Component 4 Recovering Data
Sir,
I have an winxp OS. I made a project on School Management in Visual Basic 6. The whole project is data based. ADODC component is used by me for recovering of data instead of its coding. Provider used by me is Microsoft jet 4.0 OLEDB Provider.

Code of the use connection string is
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:Documents and SettingsAdministratorMy documentsAVMProjectAVM.mdb; Persist Security Info=False

My project run very well on my OS. But I want to write it on CD for other users.
Now I want to know that what will be the Code of the use connection string as I donít want to remove Adodc component?
Or What changes can be made in above said code of my project for the recovering of data.


Email: gbj@sify.com

ADODB: Adodc.RecordSet Or Adodc.Command Is More Efficient Way For Update Table
Friends,

My database is working in Corporate office, where more than 100 hundreds of users are simultaneously accessing the database. is it better to use a SQL procedure with Adodb.Command to update table or Adodb.RecordSet.

The problem I'm facing in RecordSet is 'DeadLock' and unexpected result.

My doubt is that " which method is faster and efficient, Command or Recordset".

Setting Up A DataRepeater In Code
Hello everyone.

I'm trying to set up a DataRepeater with a custom OCX control, but I want to avoid using and ADODC to connect it to a DB, I'd rather do this in code. However, I've had no luck trying to set it up using the DataRepeater.DataSource = rs (where rs is a RecordSet, which is what I'd like to connect it to), and no amount of fiddling with it has helped.

Does anyone know of a tutorial on this (Google and MSDN haven't been much good for me on this), or know how to do this.

All comments are appreciated.

Setting Connections In Code
I need to set the connection string, password, and record source to a sql server db in code. How can I do that? I built the connection string using the graphical interface for the adodc object and I also set the password and record source properties as well but I want to put all of that in the Sub Main procedure. Any help?

Thanks!

Setting DataFormat In Code
How can I set an objects dataformat to a boolean with the true value showing "Yes" and the false value showing "No"????

thnx,
Squirrelly1

Setting Tag Property Thru Code
I have 2 listviews(lvw1 & lvw2) and a textbox on my form. A user can move items from lvw1 to lvw2 and/or put an item in the textbox and move it to lvw2. If a user deletes items from lvw2 that were in lvw1, they must go back to lvw1. Other items are discarded. How would I do this using the Tag propoerty of the items in lvw1.

Setting Odbc From Code
How can I for example set the ODBC settings (System DSN) for a new database c:p42.mdb from code without having to manually run the odbc program? I'd like the datasource name for the new database to be P42

Thanks!

ddutke

My Pictureboxes Arn't Setting Up The Way I Want, Can Someone Check My Code Please?
This is supposed to be a simple game screen, whose form and two pictureboxes dimensions are dependant on constants provided. IE, you change the constants and the size of the appropriate picture box as well as the form changes.

But for some reason one picture box is taking up the entire form, and not allowing the other on the form. When I resize, the main screen picturebox resizes to fill up all the space on the form.

I even added a click procedure for the screen picturebox so that when you click it, you get the form's width, the screen's width and the preview picturebox's width. As you stretch the form wider, I click and see the picturebox get larger, but its .width stays the same, even as the form increases.

The second picture box never makes an appearance, even though I purposefully made the form large enough for both picture boxes side by side.

I'm sure its something stupid I'm missing here... This code works if you just paste it into a form called Form1. You don't need to add any new controls or change any settings.

Thanks for giving the code a lookover


Code:
Option Explicit
Option Base 0

'Constant Declarations
Const FULLSCREEN As Boolean = False
Const SCREENWIDTH As Long = 10
Const SCREENHEIGHT As Long = 20
Const BLOCKSIZE As Long = 300
Const COLORDEPTH As Long = 32
Const MAXFRAMERATE As Long = 80

'Program Controls
Public WithEvents Screen As PictureBox
Public WithEvents Preview As PictureBox

Private Sub Form_Load()
'Sets the size and properties for the form
InitForm
'sets the screen size and properties
InitScreen
'Sets the preview Boxes size, location
'and properties
InitPreview
End Sub

Private Sub InitForm()
Form1.ScaleMode = 3
Form1.Width = (BLOCKSIZE * SCREENWIDTH) + (5 * BLOCKSIZE) + 100
Form1.Height = BLOCKSIZE * SCREENHEIGHT + 10
Form1.Caption = "Mock Tetris"
Form1.AutoRedraw = True
Form1.BorderStyle = 1
Form1.ClipControls = False
Form1.KeyPreview = True
Form1.Show
End Sub

Private Sub InitScreen()
Set Screen = Controls.Add("VB.PictureBox", "Screen")
Screen.ScaleMode = 3
Screen.Top = 5
Screen.Left = 5
Screen.Width = BLOCKSIZE * SCREENWIDTH
Screen.Height = BLOCKSIZE * SCREENHEIGHT
Screen.AutoRedraw = False
Screen.BorderStyle = 1
Screen.ClipControls = False
'Screen.BackColor = RGB(0, 0, 0)
Screen.Visible = True
End Sub

Private Sub InitPreview()
Set Preview = Controls.Add("VB.PictureBox", "Preview")
Preview.ScaleMode = 3
Preview.Top = 5
Preview.Left = Screen.Width + 100
Preview.Height = 5 * BLOCKSIZE
Preview.Width = 5 * BLOCKSIZE
Preview.AutoRedraw = False
Preview.BorderStyle = 1
Preview.ClipControls = False
Preview.BackColor = RGB(0, 0, 0)
Preview.Visible = True
End Sub

Private Sub Screen_Click()
Screen.Cls
Screen.Print "Form width: " & Form1.Width
Screen.Print "Screen width: " & Screen.Width
Screen.Print "Preview width: " & Preview.Width
End Sub

Setting Format Of Datatype Through Code?
Using VBA, I have created a table in my access database. Within the table I have successfully created a field that is a "Yes/No" datatype. However it does not automatically set the format of this field to "Yes/No." Is there a way to set the format of this field to "Yes/No" using vba?

Determining Regional Setting In VBA Code
How do you do it?

In other words, at run-time, I want to determine the system regional settings and be able to test against the returned info.

Of course, using something like MonthName(1), it would give me either an English name for January, or the word in some other language. But there's got to be a better way...

Any suggestions?

Setting DataReport Labels From Code
Hi Team

Can I set data report labels from code.

I can't see the labels when I go Me.

Any ideas?

Thanks

FW

Setting ADO Connection String In Code
I am trying to set the ADO connection string in code to access the Biblio database included with VB 6.0. I have built the interface although not bound the controls to the data file and I have included one ADO control on the form. I need help modifying this code to make the string work since I keep getting a "variable not defined" error message. Thanks in advance for your help.

Option Explicit

Private Sub Form_Load()
adoData1.ConnectionString = "Provider=Microsoft,Jet,OLEDB.3.51;" & _
"Persist Security Info=False;" & _
"Data Source=C:Program FilesMicrosoft Visual" & _
"StudioVB98Biblio.mdb"
adoData1.RecordSource = "Select * From Publishers"
End Sub

Registry Setting For Maximized Code
Hi,

Does anyone know the registry setting to make VB open it's code windows maximized by default.

Regards

Chris Adams

Setting A Program Inside A Tab In Code?
Ok I have had problems with this ever since the beginning of time. I have a set of tabs and I want to set a new textbox for a new tab. If you have seen the text editors that use tabs then you know what im talking about. Like you select new document and a new tab appears with a new textbox in it.. How would you set a new textbox to be inside the tab?

Copyright © 2005-08 www.BigResource.com, All rights reserved