By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,222 Members | 1,129 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,222 IT Pros & Developers. It's quick & easy.

open Access Form from hyperlink with filter

P: 6
I have tried to search the forum but kept getting blank page so I apologise if this has already been posted somewhere.

I am a GIS officer and we use a mapping software called Exponare Public which is web based and allows non mapping people to view our datasets without being able to change them.

Within this software we can do hyperlinks out. What I would like to do is have a link which opens up a form with all the asset information in it, including photos and maintenance etc.

looking around I have found that the best way probably to do this is write the asset ID out into a command line switch, witch will then open up the database and hopefully write the asset ID in so that the form opens to the correct data.

The command line is;
"\\kangaroo\groups\$Technical Services\Asset Management\$Current AM Documents\Asset Condition Assessments\Buildings Condition Assessments\condition assesment 2007\Gannawarra V3.mdb" /cmd "12"

where i am opening a mdb called gannawarra V3 and trying to pass the asset_ID of 12 into the db.

Within the MDB I have writen a function as follows:

Function CheckCommandLine()
Dim stLinkCriteria As String
stLinkCriteria = Command()
DoCmd.OpenForm "assets", , , "[AssetID] = " & stLinkCriteria
End Function\

I then have an autoexec macro which runs the function.

This is as far as I get as it doesn't seem to be passing the asset id in at all. I have tried variant, string and integer but none of them work. it is crashing at the asset ID = "part with a runtime error '3075' syntax error (missing operator_ in query expression '[AsserID] = '

Not sure where is is wrong, If anyone has done this before and can help out that would be absolutly fantastic, if anyone has any other way to do this that would be apreciated too.


Dec 8 '08 #1
Share this Question
Share on Google+
6 Replies

Expert 2.5K+
P: 3,072
Hmm, never used Access with a command line interface, but there's an alternative.
Just create a textfile holding the assetID and link a table to that file.
(This file will have to be filled/overwritten from your application with the correct ID)
Create a query where you JOIN the linked textfile field with the table holding the data.
This query can be used for your form.
Next create the database and set in the startup your form as the first to be displayed.

Now you're able to fill the textfile and start the database to show the value.

Getting the idea ?

Dec 8 '08 #2

P: 6
Thanks Nico, I will give it a go, sounds simple enough.
Dec 8 '08 #3

Expert 2.5K+
P: 3,072
Don't hesitate to post when stuck :-)

Dec 8 '08 #4

Expert 5K+
P: 8,624
Hello Laura!

The following code will Open the Northwind Database in the C:\Test Directory and pass to it the Command Line Argument (/cmd) of "Fuller". Employees is designated as the Start Up Form, and when it opens Code placed in the Open() Event of the Employees Form will create a Filter based on the LastName Field. The Filter will read the value of the Command() Function, create the Filter based on it, then display the appropriate Record, namely [LastName] = 'Fuller'. The code has been tested and is fully operation. Hopefully it will point you in the right direction.
Expand|Select|Wrap|Line Numbers
  1. "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "C:\Test\Northwind.mdb" /cmd "Fuller"
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.   Me.Filter = "[LastName] = '" & Command & "'"
  3.   Me.FilterOn = True
  4. End Sub
P.S. - As previously stated by Nico, we are here if you get stuck.
Dec 9 '08 #5

P: 6
Thanks Adezii,

I ended up adapting the Northwind solution that you put up. It worked perfectly once I made some adjustments to my start up script so that it would only open up the form if command existed.

However, stupid me was thinking that just because I could get the command to work from a dos prompt it would work no problems from Exponare. Obviously this was not the case. Exponare runs as a web browser, and although I had hotlinked already to excel and word docs, I forgot that they were opening up in Explorer, not in their native programs.

Unfortunately access doesn't do this. So unless I want to convert all my pretty, complicated forms into data access pages and open them over the internet (which always causes security problems with pop ups) I can't do a hyperlink to access from a web browser.

Does anyone have any ideas????

Thanks heaps for your help already, I will use this solution in something just so all the time I wasted isn't actually wasted :)


Dec 9 '08 #6

Expert 5K+
P: 8,624
I think what it basically boils down to is that you cannot pass the /cmd Switch to an Access Database via a Hyperlink, at least to the best of my knowledge. Can Exponare pass a Cookie or Text File to the Client's PC that the Start Up Form can read? (Long Shot, I know!)
Dec 9 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.