473,569 Members | 2,901 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 "documentna me" 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 4004
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
4498
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 needed to account for apostrophes, which I had already done, and replaced line breaks with html line breaks on my page which displays this stuff....
1
6973
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 know its something to do with a blank or null record as the code works fine when i enter all details in the first record. If i omit data form the...
8
12072
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 combobox. What is the solution? Thank you in advance.
2
7347
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
3254
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 the values are either of the field are "IACUC" or "IBC". If the value is IACUC, I want the IACUC report to send, if IBC the IBC report to send. The...
1
3308
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 does various other actions. Is it possible to display the text box just for the current record, rather than it displaying for all following records...
7
6872
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 expression should return the 4 leftmost characters of the FilmNo
1
4329
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 logic for a date field. i.e. theValue.defaultvalue = "#" & theValue.value & "#" I can't get this to work for some reason and I can't figure out...
1
3020
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 Enter key, it display the details. Now when I again select vlan from list and press Enter key, following error occurs. Error Type: ADODB.Field...
0
7693
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.