Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 7th, 2009, 12:21 PM
YOO YOO is offline
Registered User
 
Join Date: Aug 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Angry problem in codings

Private Sub CHECKNAME()
'IF SURNAME AND OTHER NAME IS NOT BLANK AND MO=TRUE
If Len(Trim(custs)) <> 0 And Len(Trim(custna)) <> 0 And MO = True Then

'DECLARING VARIABLES
Dim bool As Boolean
Dim rcd As Recordset
Dim dbs As Database
'SET VARIABLE DBS TO USE THE CURRENT DATABASE
Set dbs = CurrentDb
'RUN QUERY
Set rcd = dbs.OpenRecordset("SELECT NAME, SURNAME FROM CUSTOMER WHERE NAME=TRIM('" + Forms![CUSTOMER MAINTENANCE]!Name + "') AND SURNAME=TRIM('" + Forms![CUSTOMER MAINTENANCE]!surname + "')")
'IF NAME ENTERED ALREADY EXISTS
If rcd.RecordCount > 0 Then

'SET FOCUS TO TEXTBOX SURNAME
custs.SetFocus
'DISABLE SAVE BUTTON
SAVEC.Enabled = False
'SET CHECKN TO TRUE
CHECKN = True
Else
'SET CHECKN TO FALSE
CHECKN = False
End If
End If
End Sub


can anyone debug the error in red??thanks
 
Old August 7th, 2009, 02:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

This is vb6 forum, so I assume you are using VB6.. so, to access a control in your form (and a property of the control) you use . and not ! (You use ! to access a field in a recordset).
You copy this from acces??? you have to use "me" instead of "form", and that could be also removed, because with only the name of the control it will work.

REading further, what is "CUSTOMER MAINTENANCE"???
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old August 7th, 2009, 04:49 PM
YOO YOO is offline
Registered User
 
Join Date: Aug 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hi there!!!thanks

thanks so much for replying!!i'll try replacing it and see wat happens!!!
customer maintenance is where customer records can be maintained..for ex.adding,deleting,undoing,editing records about customer!!
 
Old August 7th, 2009, 05:25 PM
YOO YOO is offline
Registered User
 
Join Date: Aug 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default PROBLEM AGAIN!!

RUN TIME ERROR '3061'-too few parameters. Expected 2.
WHAT SHALL I DO????
HELPP
 
Old August 7th, 2009, 09:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

mmm.. in line 13??? ;)

how should I know, can you debug it and tell us where do you receive that error???
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.