473,503 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving field value from current record -> syntax error

2 New Member
Hi,

Please, can someone help me? My problem:
I have put a command button onto a form, which retrieves two field values from the current record. With these two values, I am able to open a document from Access.
Default value of field "documentname" is "x"
Running the code, I get a syntax error
The code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Knop46_Click()
  2.  
  3. Dim path As String
  4. Dim name As String
  5. path = "c:\Documents and Settings\Test\My Documents\Docs\"
  6. name = Trim(Me!documentname)
  7. If name="x" <------ here I get a syntax error!
  8. Then
  9. MsgBox "No filename present (x = no name exists)"
  10. Else
  11. Application.FollowHyperlink [path] & [name]
  12. End If
  13. End Sub
  14.  
Jan 16 '08 #1
4 3995
Rabbit
12,516 Recognized Expert Moderator MVP
Please use code tags.

Both path and name are reserved keywords in Access/VBA. You should rename your variables.
Jan 16 '08 #2
Delerna
1,134 Recognized Expert Top Contributor
also, dont know if you moved it for the example but the Then statement should be on the same line as the if and the condition
Jan 16 '08 #3
Rabbit
12,516 Recognized Expert Moderator MVP
also, dont know if you moved it for the example but the Then statement should be on the same line as the if and the condition
That's probably it, good catch.
Jan 17 '08 #4
achroiet002
2 New Member
Hi all,

Thanks for the solution, problem solved!
Jan 19 '08 #5

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

Similar topics

8
4495
by: middletree | last post by:
What's wrong with this code? strLongDesc = Replace(Replace(Replace(Replace(Trim(Request.Form("LongDesc")),"'","''"),vbC rLf,"<br>"),"<",&lt;),"<",&gt;) Background: This field is a textarea, and I...
1
6972
by: Colin Graham | last post by:
I am writing this piece of code to show the previous record on a control on the form but i keep getting the error message "Error 3021 no current record " and the line marked *** gets highlighted. I...
8
12066
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
2
7341
by: OSMeier | last post by:
Hi Everyone, I am hoping you can help me. I am using MS Access 2000 for this. Here is the scenario: I have two tables: tblMain -------- ID (Primary Key)
2
3240
by: ThompsonJessical | last post by:
I am trying to use a button with the vba coding for SendObject Function to email a specific report based on the value of another field of the current record. The form is a continuous form and...
1
3307
by: David | last post by:
Hi, I have a continuous form. For each record I have a field 'HeldDate' (Text Field from a table) Against each record I have a button which sets the visibility of this text box to 'True' and...
7
6863
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is...
1
4325
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
1
3013
vikas251074
by: vikas251074 | last post by:
Hello sir, I am facing some problem for which I am trying hard to solve it. But in vain. This programe is for View/Deletion. When I run program for first time, I select vlan from list and press...
0
7076
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...
0
7323
jinu1996
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...
0
7453
tracyyun
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...
0
5576
agi2029
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,...
1
5005
isladogs
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...
0
4670
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...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.