Re: How to reference a Table in a Sub procedure

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



1)
ctlImagePrefix.Text

Assuming ctlImagePrefix is a Textbox or Combobox, try using
ctlImagePrefix.Value

The Text property is be tricky to use because it requires that the specified
control have the focus. The Value property has no such requirement. This
*may* be why your code wasn't working, but I would have expected a different
error message

2)
If you have a table named Images in the current db then "SELECT * FROM
Images.." is fine.

However, *if* you wanted to do something like this....
"SELECT * FROM " & objTable & "WHERE....."
You declared objTable as an object but the select statement wants a text
string (the table name):

Here is one approach to doing the same thing correctly (also note the
additional space before the W):

Dim tdf as DAO.TableDef
Set tdf = CurrentDB.TableDefs("Images")

"SELECT * FROM " & tdf.Name & " WHERE....."

3) For easier debugging, make sure you assign your sql string to a variable:
strSQL = "SELECT * FROM Images WHERE ...."
then, place a breakpoint in your code on the line that will execute your
completed strSQL. When the breakpoint is reached type the following in the
Immediate window (View>Immediate):
?strSQL
What displays will be the string that Access is about to try to execute.
Review space/quote placements, variable/control values, etc., and edit your
code as necessary. Quite often what is wrong is very obvious.

If you are still having problems, show us the entire line that "blows up".
If its something like:

Set rs = CurrentDB.OpenRecordset(strSQL)

Then "Object Required" might not refer to a problem with strSQL, it would
probably refer to the incorrect use of CurrentDB....


HTH,


"rb608" <junkmail608@xxxxxxxxxxx> wrote in message
news:1183065295.951139.152520@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm starting to seriously push my envelope of self-taught
understanding at this point, and I'm stumped at my next step. I've
figured out how passing the variables to the sub procedure works
(whew!); and buoyed by that success, I think as long as I have all of
the same variables I need, why not just put the Recordset operation in
here too.

So, I write up a nice strSelect string ("SELECT * FROM Images WHERE
ImagePrefix = '" & ctlImagePrefix.Text & "....etc. inside the Sub
procedure.

It blows up. "Run time error 424, Object Required."

Aha! I think - I need to put the table "Images" into the variable
list on both ends. so I add ", objTable as Object" to the end of the
Sub variables and add the table name "Images" to the Call variables.
I also rewrite the string to be
"SELECT * FROM " & objTable & "WHERE....."

No good. Now I get "Compile Error: ByRef argument type mismatch."

Clearly I'm over my head here. I've never gotten this deep into the
bowels of Access. I could do trial-and-error for days and never
figure this out. Needless to say, the Help file isn't much help.
What's the correct syntax/procedure for what I'm trying to do?

Tx again.



.



Relevant Pages

  • Re: Loading image in Orca/Pascal
    ... necessary to load images using Orca - again, ... Also required is the P2GSString to convert the Pascal string into a GS/ ... if ToolError = 0 then begin ... srcHdl:= NewHandle(srcSize, ...
    (comp.sys.apple2.programmer)
  • Re: storing path only to database
    ... is about 5gb..the type of file that i have to store is images ... cannot store all the images because of the limitation...now...i want to ... Dim MyFolder As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: how to set background of TD without an ID to none
    ... So whatever is assigned to the document.body.background attribute must be a string. ... table cell, but nothing instead, or second option, a transparent gif ... document.write which does something with images messes it up, ... happyimages = el.getElementsByTagName; ...
    (comp.lang.javascript)
  • Re: How to reference a Table in a Sub procedure
    ... string, by itself, cannot possibly generate an 424 error. ... figured out how passing the variables to the sub procedure works ... I think - I need to put the table "Images" into the variable ... the Help file isn't much help. ...
    (microsoft.public.access.formscoding)
  • Re: SqlDataReader.GetBytes Results in an System.InvalidCastExcepti
    ... For the bytes arrays you need a memorystreem to convert them to images ... private void SqlBlob2File(string DestFilePath, string id) ... SqlCommand cmd = new SqlCommand("SELECT Body FROM ActivityMimeAttachment ... > added two fields ID as a UID and MyText of type Text. ...
    (microsoft.public.dotnet.framework.adonet)