473,387 Members | 1,578 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,387 software developers and data experts.

sub or function not defined

1
hi guys,im a newbie here.. i have a piece of coding.. but i get an error,pls help,its for my final project...:(
i have highlighted where i get an error.. pls help. if u must know i got the source code online and modified it to suit my requirements.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Explicit
  3. Dim db As Database
  4.  
  5. Dim rs As Recordset
  6.  
  7. Private Sub Form_Load()
  8.  
  9. On Error GoTo ErrHandler
  10. Set db = OpenDatabase(App.Path & "\sad.mdb")
  11. Set rs = db.OpenRecordset("supplier", dbOpenDynaset)
  12. Exit Sub
  13. ErrHandler:
  14. Dim ErrNum, ErrDesc, ErrSource
  15. ErrNum = Err.Number
  16. ErrDesc = Err.Description
  17. ErrSource = Err.Source
  18. MsgBox "Error# = " & ErrNum & vbCrLf & "Description = " & ErrDesc & vbCrLf & "Source = " & ErrSource, vbCritical + vbOKOnly, "Program Error!"
  19. Err.Clear
  20. Exit Sub
  21.  
  22. End Sub
  23.  
  24. Private Sub cmd_add_Click()
  25. On Error GoTo ErrHandler
  26.  
  27. Dim SupplierID, Name, Address
  28. If txtID.Text = "" And txtName.Text = "" And _
  29. txtAddress.Text = "" Then
  30.  
  31. MsgBox "You must enter information in for at least the supplier" _
  32. , vbOKOnly + vbCritical, "Data Required"
  33. ClearForm
  34.  
  35. Exit Sub
  36. End If
  37. SupplierID = Encode(txtID.Text)
  38. Name = Encode(txtName.Text)
  39. Address = Encode(txtAddress.Text)
  40. With rs
  41. .AddNew
  42. !SupplierID = ID
  43. !Name = Name
  44. !Address = Address
  45.  
  46. .Update
  47. End With
  48. ClearForm
  49. GetEntries
  50. Exit Sub
  51. End Sub
  52.  
  53.  
  54. Private Sub Form_Unload(Cancel As Integer)
  55. rs.Close
  56. db.Close
  57. End Sub
Jan 26 '09 #1
2 3868
smartchap
236 100+
Dear Jugal

In cmd_add click event write code for label ErrHandler.
Write code for ClearForm and GetEntries. I think ur code will be alright.

Always believe in God.
Jan 27 '09 #2
Keithuk
10
Welcome to Bytes jugal.

@jugal
I see no error line hightlighted.

I only see what smartchap has picked up you are using an error trap but there is no ErrHandler in that Sub. You have stated and shown it in Form_Load.

Also when you declare variables use the correct type

Dim SupplierID, Name, Address

All those will be Variants because you have stated anything otherwise.

Dim SupplierID As Long, Name As String, Address As String

I would avoid using Name as a variable because Name is a Keyword in VB.

I'm betting again your another VB use that isn't using Option Explicit. If you don't know what it means or how to set it up then just ask.
Feb 3 '09 #3

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

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
12
by: Gaurav Veda | last post by:
Hi ! I am a poor mortal who has become terrified of Python. It seems to have thrown all the OO concepts out of the window. Penniless, I ask a basic question : What is the difference between a...
33
by: Pushkar Pradhan | last post by:
I'm using clock() to time parts of my code e.g. clk1 = clock(); /* code */ clk2 = clock(); /* calculate time in secs */ ...... clk1 = clock(); /* code */ clk2 = clock();
21
by: Stephen Biggs | last post by:
Given this code: void f(void){} int main(void){return (int)f+5;} Is there anything wrong with this in terms of the standards? Is this legal C code? One compiler I'm working with compiles this...
3
by: chreo | last post by:
I have user-defined function in MSSQL which returns Table (with 10 columns) (sorry for Polish names) CREATE FUNCTION PACZKI_Z_AKCJI (@AKCJA_ID int) RETURNS TABLE RETURN SELECT TOP 100...
13
by: Anthony de Almeida Lopes | last post by:
Hello, I am wondering why it is not possible to have a function-like macro like the following: #define __nothread(name) do { \ #ifdef _PTHREAD_H ...
1
by: prads | last post by:
Hello, I found this waitbar functioning pgm in a forum which does the same work as a matlab waitbar. However this pgm has an error and i cudnot figure it out. Can anyone pls correct it. Thanks,...
4
by: prads | last post by:
Hello, this waitbar function (similar to the one in matlab) in C++ pops an error. Pls correct the error for me. Thanks, prads <code> #include <octave/oct.h> #if defined (HAVE_TERM_H) # ...
11
by: aarklon | last post by:
Hi all, I have heard many discussions among my colleagues that main is a user defined function or not. arguments in favour:- 1) if it is built in function it must be defined in some header...
21
by: H9XLrv5oXVNvHiUI | last post by:
Hi, I have a question about injecting friend functions within template classes. My question is specific to gcc (version 3.4.5) used in combination with mingw because this code (or at least code...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...

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.