Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2006

Tip: Looking for answers? Try searching our database.

Just get started - please help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
alvin Kuiper - 06 Feb 2006 08:01 GMT
Hi
I try to get a record from a table  like this:
Private Sub Tekst0_Exit(Cancel As Integer)
Dim con As Connection
Dim rs As Recordset
Dim bruger As String
bruger = Tekst0.Text
Dim strsql As String
strsql = ("select * from bruger where navn = '"&bruger&"'"), con

rs.Open (strsql)

If Not rs.EOF Then
MsgBox ("Du er " & rs.Status)
Else
MsgBox ("Du har ikke ret til denne side")
End If
End Sub

I know this is wrong so can someone help just to get started, then i believe
i can go alone with this, i'm normally using Asp .

Alvin
Arvin Meyer [MVP] - 06 Feb 2006 11:56 GMT
Try:

Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim bruger As String
bruger = Tekst0.Text
Dim strsql As String

Set con = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")

con.Open "your_database_connection_string"
rs.Open "select * from bruger where navn = '"&bruger&"'"
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

> Hi
> I try to get a record from a table  like this:
[quoted text clipped - 19 lines]
>
> Alvin
alvin Kuiper - 06 Feb 2006 15:27 GMT
Thanks

But shall i use all this
I understand i shall use this if i wanr to connect to another DB
but i have open my access working in access so why shall i
use a ADODB.Connection

I don't understand this

Alvin

> Try:
>
[quoted text clipped - 40 lines]
> >
> > Alvin
Douglas J Steele - 06 Feb 2006 16:44 GMT
The Recordset object needs to be told what Connection to use. If you've got
an existing Connection object open, you can use that, but you still must
associated that Connection object to the Recordset object you're creating in
your routine.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Thanks
>
[quoted text clipped - 51 lines]
> > >
> > > Alvin
Brendan Reynolds - 06 Feb 2006 17:13 GMT
If your code and data (or linked tables) are in the same MDB or ADP, you can
use CurrentProject.Connection. For example ...

Public Sub ListData()

   Dim rst As ADODB.Recordset
   Set rst = New ADODB.Recordset
   rst.Open "SELECT * FROM Classification", CurrentProject.Connection
   Do Until rst.EOF
       Debug.Print rst.Fields(0)
       rst.MoveNext
   Loop
   rst.Close

End Sub

Otherwise, when the code is execting in an MDB or ADP that does not contain
or link to the data, you need to create and open the connection, much as you
would in ASP ...

Public Sub ListExternalData()

   Dim cnn As ADODB.Connection
   Dim rst As ADODB.Recordset

   Set cnn = New ADODB.Connection
   cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
       "Data Source=C:\Program Files\Microsoft
Office\OFFICE11\SAMPLES\Northwind.mdb;" & _
       "Persist Security Info=False"
   cnn.Open
   Set rst = New ADODB.Recordset
   rst.Open "SELECT * FROM Employees", cnn
   Do Until rst.EOF
       Debug.Print rst.Fields(1)
       rst.MoveNext
   Loop
   rst.Close
   cnn.Close

End Sub

Signature

Brendan Reynolds
Access MVP

> Thanks
>
[quoted text clipped - 51 lines]
>> >
>> > Alvin
alvin Kuiper - 06 Feb 2006 21:33 GMT
Sorry i find out hoq

rst.Fields("sjov")

so thanks for your help
Alvin

> If your code and data (or linked tables) are in the same MDB or ADP, you can
> use CurrentProject.Connection. For example ...
[quoted text clipped - 93 lines]
> >> >
> >> > Alvin
alvin Kuiper - 06 Feb 2006 21:34 GMT
Thanks
Now i understand

Just one more if you can help
In my table i have a field name: "sjov"
then i want to see what in this fild
and in my way i want to write
rst.sjov

But this don't work????

Best regards alvin
and thanks for the help

> If your code and data (or linked tables) are in the same MDB or ADP, you can
> use CurrentProject.Connection. For example ...
[quoted text clipped - 93 lines]
> >> >
> >> > Alvin
SteveS - 07 Feb 2006 09:38 GMT
Try using bang (!), instead of dot (.):    rst!sjov

I think you can also use:   rst.Fields("sjov")

Signature

Steve S.
--------------------------------
"Veni, Vidi, Velcro"
(I came, I saw, I stuck around.)

> Thanks
> Now i understand
[quoted text clipped - 109 lines]
>>>>>
>>>>>Alvin
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.