Connecting Tech Pros Worldwide Help | Site Map

Having to click twice to enter new record

Newbie
 
Join Date: Aug 2009
Posts: 22
#1: Sep 2 '09
Below is my code for a button to add new record.
it works but only after a second click and I don't know why. please help.

currentcontact is a global variable. It takes the value of contactid (CID) of the customer I wish to create new record for.
New record is created
I put currentcontact value inot contactid of new record
I call a function that sets states of certain fields
I call a procedure that pulls current VAT rate according to date
Expand|Select|Wrap|Line Numbers
  1. Dim ConfirmRate As Double
  2.  
  3. If Nz(Me.CID, 0) <> 0 Then
  4.  
  5.     CurrentContact = Me.CID
  6.     DoCmd.GoToRecord , , acNewRec
  7.     Me.ContactID = CurrentContact
  8.     Call FieldLockState
  9.     Call VATRateCheck(Date, Date, ConfirmRate)
  10.     Me.VATrate = ConfirmRate
  11.     Me.Refresh
  12. Else
  13.     MsgBox "Choose Client First"
  14. End If
FishVal's Avatar
Expert
 
Join Date: Jun 2007
Location: Israel
Posts: 2,584
#2: Sep 3 '09

re: Having to click twice to enter new record


Have you tried to debug your code?
Newbie
 
Join Date: Aug 2009
Posts: 22
#3: Sep 5 '09

re: Having to click twice to enter new record


I did using msgboxs and debug.print but to no joy.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,672
#4: Sep 5 '09

re: Having to click twice to enter new record


I'll assume for now you haven't read my last reply to you in your other thread, and have never noticed any of the edit comments I've been to the trouble of posting for you about using the [ CODE ] tags.

Next time though, I will have to issue you an infraction. The tags are not optional and must be used when posting code.

On to the subject at hand :
Fish posted a link behind the word debug. I suggest you visit the thread and allow it to teach you some very useful debugging techniques.

Let us know how you get on.
Reply


Similar Microsoft Access / VBA bytes