Hi, im having trouble carrying variables across a form, ive looked on here and other sites but cant find anything that helps me, or i might not be searching for the right terms, so i though i would post to see if anyone can help me.
what i need is to carry certain aspects of data from splash form to my main form which im currently developing.
this is the code im usign for the frmSplash
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
Private Sub Form_Load()
Dim statement As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Image1.Height = 615
Dim db_file As String
lbversion.Caption = "Version: " & App.Major & "." & App.Minor & "." & App.Revision
' Get the data.
db_file = App.Path
If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
db_file = db_file & "AlbumData.mdb"
Dim a$
Dim b$
b$ = db_file
On Error GoTo filenotfound
a$ = GetAttr(b$)
' Open a connection.
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
conn.Open
Exit Sub
me.hide
form1.show
filenotfound:
MsgBox "The Database file: " & db_file & vbCrLf & "Cannot be found, please make sure that it exists and run again.", vbCritical, "File not Found"
Unload Me
End Sub
what i want to do is carry the variables " db_file " and " conn " across to form1 so for example i could do
label1.caption = "" & db_file or
test1.text = "" & db_file
but if anyone can help me in showing me how i can do that i would be most greatful. thank you very much.
Kind Regards,
Devon.
1 5049
Hi, im having trouble carrying variables across a form, ive looked on here and other sites but cant find anything that helps me, or i might not be searching for the right terms, so i though i would post to see if anyone can help me.
what i need is to carry certain aspects of data from splash form to my main form which im currently developing.
this is the code im usign for the frmSplash
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
Private Sub Form_Load()
Dim statement As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Image1.Height = 615
Dim db_file As String
lbversion.Caption = "Version: " & App.Major & "." & App.Minor & "." & App.Revision
' Get the data.
db_file = App.Path
If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
db_file = db_file & "AlbumData.mdb"
Dim a$
Dim b$
b$ = db_file
On Error GoTo filenotfound
a$ = GetAttr(b$)
' Open a connection.
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
conn.Open
Exit Sub
me.hide
form1.show
filenotfound:
MsgBox "The Database file: " & db_file & vbCrLf & "Cannot be found, please make sure that it exists and run again.", vbCritical, "File not Found"
Unload Me
End Sub
what i want to do is carry the variables " db_file " and " conn " across to form1 so for example i could do
label1.caption = "" & db_file or
test1.text = "" & db_file
but if anyone can help me in showing me how i can do that i would be most greatful. thank you very much.
Kind Regards,
Devon.
Hi there,
At the moment you have declared these variables as local variable, you need to declare a variable as public for a longer scope. Please refer below modified code segment, i've moved these variables to a module file.
Kindly refer below attached links for further reading & understanding, hope it helps. Good luck & Take care. Variable Declaration in Visual Basic Variable Scope
Module code -
Public conn As ADODB.Connection
-
Public rs As ADODB.Recordset
-
-
Public db_file As String
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ralph Freshour |
last post by:
I was reading about PHP variable scoping - it doesn't seem to support
carrying any variables from one web page to another - how is this
usually done? I have a lot of php variables created on my...
|
by: Jessica Loriena |
last post by:
I'm trying to write a simple "register form / validate and store in
database / show welcome screen" application with ASP.Net. With
conventional ASP, I used Session variables and it went something...
|
by: Ani |
last post by:
Hi,
I need to carry the user input across pages and then at
the end insert all the values into the DB. How do I best
accomplish this task in ASP.Net. I am a novice , please
give me some simple...
|
by: Cowboy \(Gregory A. Beamer\) |
last post by:
Background:
-------------
The idea started as a single sign on type of application. Having tested it
before, I knew we could institute single sign on using the same
Authentication Cookie name (in...
|
by: JezB |
last post by:
I have various web pages in two different "web application" project
assemblies (WebClient1 and WebClient2), and another "class library" assembly
WebLib. I have methods in the library which set and...
|
by: Ricardo Furtado |
last post by:
I'm making a Web Site with Visual Basic .Net and i need the user to log on in
order to have access to some pages on the web site. How can i maintain the
username and password variables from the...
|
by: Japhy |
last post by:
Hello,
I need to save values typed into forms across several scripts, before
the user actually 'submits' the form to update the mysql db.
I have been exploring ways to do this, and looking for...
|
by: Sandman |
last post by:
I dont think I understand them. I've read the section on scope in the
manual inside out.
I'm running PHP 5.2.0 Here is the code I'm working on:
//include_me.php
<?php
$MYVAR = array();
global...
|
by: Kurrent |
last post by:
I have some data from text fields that are being passed over through a
form that I am displaying with the $_POST superglobal. Once i have
echo'd out this data onto the next page, i'd like to...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |