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

Access Form with some VB 6.0 code

ok. I have a form that I have created in Access and I am using a bit of VB 6.0 code behind the scenes.
On the form I have a combo box called "Payment Method" and in the combo box the choices are: check, cash, free. Then I have a textbox called "CheckNum" for the user to enter a check number when "check" is chosen. What I'm wanting to do is - when the user chooses "check" from the combo box I want it to prompt the user to enter a check number if they have by passed that field. Here is the code that I have and it is not working. Please help!
Expand|Select|Wrap|Line Numbers
  1. Private Sub PrintRec_Click()
  2. On Error GoTo Err_PrintRec_Click
  3.  
  4. Dim rstTrans As New ADODB.Recordset
  5. Dim fld As ADODB.Field
  6. Dim strField As String
  7. Dim curCount As Currency
  8.  
  9. /////// Here is the code in question
  10.  If Me.cboPaymentMethod = "Check" And CheckNum.Text = "" Then 'Check number not entered
  11.          MsgBox "You must enter a check no."
  12.     CheckNum.SetFocus
  13.  
  14. End If
  15.  
  16.  
  17. rstTrans.Open "dbo_tbl_Transactions", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
  18.  
  19.     If IsNull(Me.TempTransNumID.value) Then
  20.     'this is new record
  21.     rstTrans.AddNew
  22.     Else
  23.     'to stay on the record that was just inserted for editing
  24.     rstTrans.Find ("TransNumID=" + Str$(Me.TempTransNumID))
  25.     End If
  26.  
  27.  
  28. rstTrans!TransDate = Me.TransDate
  29. rstTrans!CustomerName = Me.CustomerName
  30. rstTrans!VehType = Me.VehType
  31. rstTrans!TktType = Me.TktType
  32. rstTrans!Auth_By = Me.AuthBy
  33. rstTrans!Quantity = Me.Quantity
  34. rstTrans!SHtkt1 = Me.SHtkt1
  35. rstTrans!SHtkt2 = Me.SHtkt2
  36. rstTrans!HRtkt1 = Me.HRtkt1
  37. rstTrans!HRtkt2 = Me.HRtkt2
  38. rstTrans!TransPayAmt = Me.TransPayAmt
  39. rstTrans!PaymentType = Me.txtPaymentType
  40. rstTrans!PaymentMethod = Me.cboPaymentMethod
  41. rstTrans!CheckNum = Me.CheckNum
  42. rstTrans!TransReceiptMemo = Me.TransReceiptMemo
  43. rstTrans!TransEntryTime = Now()
  44. rstTrans!TransEntryUserID = appUser
  45.  
  46.  
  47.  
  48.  
  49. rstTrans.Update
  50. 'this was a new record so update the form value of TransNumID for edit
  51. If IsNull(rstTrans!TransNumID.value) <> True Then
  52.     Me.TempTransNumID = rstTrans!TransNumID.value
  53. End If
  54.  
  55.  
  56. whereClause = "NewQryShuttleHandiRideReceipt.TransNumID" & " = " & rstTrans!TransNumID
  57.  
  58. 'DoCmd.OpenReport "RptShuttle HandiRide Receipt", acViewNormal, , whereClause
  59.  
  60. rstTrans.Close
  61.  
  62. Set rstTrans = Nothing
  63. Me.cmdAddRec.Enabled = True
  64.  
  65. Exit_PrintRec_Click:
  66.     MsgBox "Record Successfully Saved! Printing Receipt."
  67.     Exit Sub
  68.  
  69. Err_PrintRec_Click:
  70.     MsgBox Err.Description
  71.     Resume Exit_PrintRec_Click
  72.  
  73. End Sub
Oct 11 '07 #1
2 1485
nico5038
3,080 Expert 2GB
The best approach is to have two buttons on the form:
[Cancel] and [Save]
Your test for the Check text to be filled should be performed when the [Save] button is pressed and the combo equals "Check". This way the user can enter the Checktext and the "Check" value in the combo in any sequence.

Getting the idea ?

Nic;o)
Oct 11 '07 #2
missinglinq
3,532 Expert 2GB
And just to clarify things, if your code is behind an Access form, it is VBA (Visual Basic for Applications) not VB6! While VBA was developed from standard Visual Basic, there are differences which, at times, are substantial. All functions available in one are not available in the other, and some identically named functions behave differently, depending on which of the two languages you're referring to and even which version of Access you're using.

Be sure to always post Access code questions here as you did, rather than in the Visual Basic forum.

Welcome to TheScripts!

Linq ;0)>
Oct 11 '07 #3

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

Similar topics

11
by: David W. Fenton | last post by:
I'm working in Access 2K quite a bit lately (with only my second project that is 100% A2K), and I've run into a number of odd problems that seem to be associated with running code. The most...
1
by: mora | last post by:
Hello. I am hoping to get some help here about connecting, directly or not, an Access database with a web site. I have done some research but have not come up with much of use. I am wondering...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
55
by: AnandaSim | last post by:
I just had a google through this NG but have not seen mention of Erik Rucker's blog entry and the new Jet: http://blogs.msdn.com/access/archive/2005/10/05/477549.aspx mentioned by Mike...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
14
by: ApexData | last post by:
I am considering building some distributable commercial applications. For about a year now, I have been using Access2000. This was my first venture into object oriented database development. ...
10
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Thank you for that. It was very...
9
by: prakashwadhwani | last post by:
Hi !! I'm about to develop a new project for a client. Should I go about it in Access 2003 or 2007 ? Purchasing it either for me or for my client is not a major consideration here ... what I'd...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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...

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.