Hi,
I recently upsized my access database to ms-sql backend but some of my vb code is not working anymore. Please help. Here is my code. It was for a simple form with combo box's to run a query.
Option Compare Database
Option Explicit
Private Sub Command5_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("Stored1")
strSQL = "SELECT [CEO-NCO Log].* " & _
"FROM [CEO-NCO Log] " & _
"WHERE [CEO-NCO Log].[Assigned To:]='" & Me.cboName.Value & "' " & _
"AND [CEO-NCO_Log].[File Type] ='" & Me.cboFile.Value & "' " & _
"ORDER BY [CEO-NCO Log].[Assigned To:]"
qdf.SQL = strSQL
DoCmd.OpenQuery "Stored1"
Set qdf = Nothing
Set db = Nothing
End Sub
7 6671
I recently upsized my access database to ms-sql backend but some of my vb code is not working anymore. Please help. Here is my code. It was for a simple form with combo box's to run a query. ...
Could you be more explicit than "not working"? What is going wrong? If you're getting an error, please describe the circumstances, and the exact wording of the message. And if possible, which line of code produces it.
Oh, and what version of VB? Or is it VBA in Access, or what?
Oops! Just spotted the DoCmd - I guess it's Access VBA.
strSQL = "SELECT [CEO-NCO Log].* " & _
"FROM [CEO-NCO Log] " & _
"WHERE [CEO-NCO Log].[Assigned To:]='" & Me.cboName.Value & "' " & _
"AND [CEO-NCO_Log].[File Type] ='" & Me.cboFile.Value & "' " & _
"ORDER BY [CEO-NCO Log].[Assigned To:]"
I admit, this is probably just my Access ignorance speaking - but could those colons be a problem? And do you need a semicolon on the end of the SQL string?
Hi,
I recently upsized my access database to ms-sql backend but some of my vb code is not working anymore. Please help. Here is my code. It was for a simple form with combo box's to run a query.
Option Compare Database
Option Explicit
Private Sub Command5_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("Stored1")
strSQL = "SELECT [CEO-NCO Log].* " & _
"FROM [CEO-NCO Log] " & _
"WHERE [CEO-NCO Log].[Assigned To:]='" & Me.cboName.Value & "' " & _
"AND [CEO-NCO_Log].[File Type] ='" & Me.cboFile.Value & "' " & _
"ORDER BY [CEO-NCO Log].[Assigned To:]"
qdf.SQL = strSQL
DoCmd.OpenQuery "Stored1"
Set qdf = Nothing
Set db = Nothing
End Sub
Hi. Your vb code does not know what database to connect to. Creating a database object does not connect you to sql server. You need a connection string
It doesn't like this line,
Set qdf = db.QueryDefs("Stored1")
I get the errror run time error 91
Object variable or with block not set
Thanks for your responses.
It doesn't like this line,
Set qdf = db.QueryDefs("Stored1")
I get the errror run time error 91
Object variable or with block not set
Thanks for your responses.
Hm... that sounds as though db hasn't been properly set. Maybe it's something to do with connecting to the database, as willakawill pointed out.
It doesn't like this line,
Set qdf = db.QueryDefs("Stored1")
I get the errror run time error 91
Object variable or with block not set
Thanks for your responses.
You have to explicity connect to sql server. CurrentDb does not do this.
I'm getting the famous error 91, but in a way I've never seen. I built a form to handle our work order system via SQL and included it in a project I had already started. The compiled project works fine on my development machine and the laptop with VB6 enterprise on it, but when I attempt to use it on a machine that doesn't have VB6 installed, it doesn't work. Everything else works except for the SQL form. Am I missing a DLL or some necessary file?
When the form comes up it's supposed to display the first record, but on the other machines the fields are just blank. As soon as I hit the new record, save record, or delete record button, I get the ERR 91 message. Like I said, no such problems on the machines with VB6.
I need to get this added soon.
Thanks
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Del |
last post by:
We have a MS SQL Server 2000 application for our shipping system. We
have created a front end application using MS Access for our order
analyst. The front end application allows the analyst to...
|
by: Peter Frost |
last post by:
Please help
I don't know if this is possible but what I would really like to do is
to use On Error Goto to capture the code that is being executed when
an error occurs.
Any help would be much...
|
by: Yannick Turgeon |
last post by:
Hello,
We are in the process of examining our current main application. We have to
do some major changes and, in the process, are questionning/validating the
use of MS Access as front-end. The...
|
by: Olav.NET |
last post by:
I am a .NET/C++ developer who is supposed to do some work with Access.
I do not know much about it except for the DB part.
Questions:
*1*
I am looking for INTENSIVE books to get quickly up to...
|
by: mikeh |
last post by:
hi. ive searched the net for days for help hope some one here can help on this.
i am using micosoft access2003.
i have a table where i import fields from seach forms. as i import a field i need...
|
by: Mark |
last post by:
Currently using MS Access 2000 and SQL Server Express. Using the
current DAO OpenRecordset code listed below, however I keep getting
the error message....
3254: ODBC --Cannot lock all records
...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: Martin |
last post by:
I have an intranet-only site running in Windows XPPro, IIS 5.1, PHP
5.2.5. I have not used or changed this site for several months - the
last time I worked with it, all was well.
When I tried it...
|
by: grmotild |
last post by:
Hello. I have trouble to use MS Access report from vb.net in VS2005.
I wrote VB.net application(based ms access database) that works perfect on client machine.
I have added report in same database...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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: 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: 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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |