473,414 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

"Argument not optional" What i need to do with this?

Keep getting this massage, "Compile Error: Argument Not Optional" and highlighted Me.txtSiteType
Trying to figure up, but failed.

Please help.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAdd_Click()
  2. 'when we click on button add there are 2 option
  3. '1. for insert
  4. '2. for update
  5.     If Me.txtSiteID.Tag & "" = "" Then
  6.         'this is for insert new
  7.         'Add data to table
  8.         CurrentDb.Execute = "INSERT INTO contoh(Site ID, Site Name, Site Type) " & _
  9.         " VALUES('" & Me.txtSiteID & "','" & Me.txtSiteName & "','" & Me.txtSiteType & "') "
  10.         Set Data = cmdAdd_Click()
  11.         MsgBox "Already Add"
  12.  
  13.  
  14.     End If
  15. End Sub
  16.  
  17.  

Thanks in advance,
Jan 27 '16 #1

✓ answered by Seth Schrock

Remove the equals sign after the CurrentDb.Execute. Also, I believe that you need square brackets around your field names because of the spaces.

6 2056
Seth Schrock
2,965 Expert 2GB
Try putting a space between your table name and the opening parenthesis as well as after the word VALUES.
Jan 27 '16 #2
Done, still got the same massage.
Jan 27 '16 #3
Seth Schrock
2,965 Expert 2GB
Remove the equals sign after the CurrentDb.Execute. Also, I believe that you need square brackets around your field names because of the spaces.
Jan 27 '16 #4
OMG!, Thanks Seth Schrock. Will get nightmare because of both square bracket and "=" only.
Jan 27 '16 #5
Seth Schrock
2,965 Expert 2GB
Glad it worked. I missed it the first time as well.
Jan 27 '16 #6
NeoPa
32,556 Expert Mod 16PB
Amira.

Some tips that may prove helpful :
  1. As a general rule it is good practice to prepare your SQL in a string variable first. That way you can show the contents of the string as well as use as one of the parameters to your procedure or method. See How to Debug SQL String.
  2. Never use the result of the CurrentDb() function call directly. Always assign it once to a variable and then use the variable for all future references. CurrentDb() is a function that actually returns a different value each time it's run - even though each value represents the same database object.
  3. When referencing procedures, either subroutines or functions, it makes it easier to read your code if you use the Call syntax. EG. The syntax for Execute would be like :
    Expand|Select|Wrap|Line Numbers
    1. Call dbVar.Execute(Parameter#1, Parameter#2, etc)
Jan 27 '16 #7

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

Similar topics

5
by: Dom | last post by:
Does anybody have these programs: Direct I/O - full version, licence key, key generator, crack... anything! Multimedia Tools 2.0 for VB6 - full version or crack (I found only crack for delphi...
7
by: Ragnorack67 | last post by:
Hi, is it possible to change a form text field to this.blur() from a separate function? So, what I want to do is when a button is click it will runblur(), and cause form input name "xyz" to go...
6
by: greenflame | last post by:
I need code to compute the determinant and inverse of a matrix. for example the determinant and inverse of:
3
by: johnb41 | last post by:
I am building a .net app that does some simple image tasks (Tiff files): viewing Tiff, viewing thumbnails from multipage tiff, rotation, page (frame) deletion, etc. The problem is that it is so...
4
by: sdavies6 | last post by:
I have no idea how this got onto my month old HP computer; I must have downloaded something which uses it. It seems I have a folder and subfolders equaling about 29 MB, called PYTHON 22. The...
0
by: smerf | last post by:
Watch the first video about this Delphi error reporting tool. This is great! http://www.madshi.net/madExceptVideos.htm Does anyone know of anything similar for .Net?
0
by: nkotbox | last post by:
I have this script to enable/disable my wireless nic on my laptop. Is it possible for the scripts icon or shortcut to the script to change icons depending on whether or not the nic is enabled. So if...
1
by: Debby Dadebo | last post by:
Hello, Please I need a program code that will convert roman numerals to integers. I will be glad if you can add the programs algorithm and flowchart. Thanks and God Bless you
1
by: CranberryPunch | last post by:
{block:HasTags} {block:Tags} <font size="2"> <font color="#FFFFFF"> <a href="{TagURL}">{Tag}</a> </font> </font> {/block:Tags}...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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
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,...
0
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
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...

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.