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

VBA for form open

Hello friends, please can anyone solve my issue

I have used VBA on TrNo filed as per shown on Code Tag for below following forms open purpose so it is not working properly only open BT_DepositEntryModify form otherwise not working. I think just need to change VBA code so please replay how to give a VBA in this case. I have attached the dB and Screenshot with Explanation.

Forms:
BT_DepositEntryModify
BT_WithdrawEntryModify

Expand|Select|Wrap|Line Numbers
  1. Private Sub TrNo_Click()
  2. On Error GoTo ErrorHandler
  3.  If Left(Me!ID, 1) <> "D" Then
  4.     DoCmd.OpenForm "BT_DepositEntryModify", acNormal, "BT_DepQry", "TrNo= " & Val(Me!TrNo)
  5.  Else
  6.     DoCmd.OpenForm "BT_WithdrawEntryModify", acNormal, "BT_WDrawQry", "TrNo= " & Val(Me!TrNo)
  7.  End If
  8. ErrorHandler:
  9. End Sub
Thanks,
Sandhya.
Attached Images
File Type: jpg BT Screenshot.jpg (52.3 KB, 161 views)
Attached Files
File Type: zip BT.zip (426.3 KB, 69 views)
Dec 4 '14 #1
12 1644
twinnyfo
3,653 Expert Mod 2GB
You don't tell what Me!ID is or the values found there. I can't open zip files at work. Are you getting errors? Please explain.
Dec 4 '14 #2
Thanks for replay
There is no error but in the VBA code two type’s conditions shown for form opening so 1st one is BT_DepositEntryModify form this is working well.
But 2nd one is BT_WithdrawEntryModify form this form is can’t open when I click on TrNo as per screenshot and in this form place also open 1st one BT_DepositEntryModify form.
So I need to open 2nd form also BT_WithdrawEntryModify form as per TrNo field require.
Dec 4 '14 #3
twinnyfo
3,653 Expert Mod 2GB
Yes, but your code is dependent upon ME.ID, and since you haven't shared what values are found in that fields, TrNo is immaterial.
Dec 4 '14 #4
Yes, I’m not sure that code is correct or wrong just i tried. Forms & Query fields as per below following details

Form: BT_DepositEntryModify (Query: BT_DepQry also same fileds)
Fields:
ID
TrNo
TranDate
Particulars
ChqTNo
ChqPassedRejected
Deposits

Form: BT_WithdrawEntryModify (Query: BT_WDrawQry also same fileds)
Fields:
ID
TrNo
TranDate
Particulars
ChqTNo
ChqPassedRejected
Deposits
Withdraws
Dec 4 '14 #5
twinnyfo
3,653 Expert Mod 2GB
What are the values that you will find in the ID field?

Since your If...Then statement is checking that value, but it never opens the other form, this is where you must start your troubleshooting--which is why I keep asking about it.....
Dec 4 '14 #6
ID filed value is AutoNumber & format is start with (D1, D2, D3 )
TrNo filed Value is Serial number & format is start with (1,2,3)
Dec 4 '14 #7
twinnyfo
3,653 Expert Mod 2GB
Because of Line 3:

Expand|Select|Wrap|Line Numbers
  1. If Left(Me!ID, 1) <> "D" Then
And the formate of ID is always "Dx", you will ALWAYS open the first form--no matter what. This is where your problem is.
Dec 4 '14 #8
DoCmd.OpenForm "BT_WithdrawEntryModify", acNormal, "BT_WDrawQry", "TrNo= " & Val(Me!TrNo)

this is the problem so any chance to changes VBA ? for second form also need to be open ?
Dec 4 '14 #9
Rabbit
12,516 Expert Mod 8TB
The problem isn't the code to open the form. The problem is the code that decides which form to open.
Dec 4 '14 #10
Attached the as per screenshot Bank Transaction Details form in the last 2 rows records is Form: BT_WithdrawEntryModify & first 2 rows records is Form: BT_DepositEntryModify
Both of differences is Withdraws Rs. & Deposits Rs. field amounts so in this case I need to form open If Amount is Withdraws Rs. filed side then will be open the form: BT_WithdrawEntryModify Or Deposits Rs. field side then will be open the form: BT_DepositEntryModify that’s way am using VBA on TrNo filed but can't workout.
Attached Images
File Type: jpg Issue screenshot.jpg (67.0 KB, 100 views)
Dec 5 '14 #11
Rabbit
12,516 Expert Mod 8TB
The problem is that the TrNo has nothing to identify whether or not that row is a deposit or a withdrawal. And neither does the ID field.
Dec 5 '14 #12
Thanks for suggestions.. I will change the structure and after will try to other sources.
Dec 5 '14 #13

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

Similar topics

9
by: Shyguy | last post by:
I have two forms that both open the same (3rd) form. The third form does the same thing, but a little differently depending on which form it is opened from. Is there a way I can check which form...
2
by: Ron Rohrssen | last post by:
I'm trying to use the ErrorProvider in order to validate my form. This is working well except that in the event of a failure on my modal dialog, I'd like to keep the dialog open. I open the...
2
by: Kaur | last post by:
Hi, I have developed an application in MS Access 2000 where I am trying to highlight a record in the list box in form 2 based on the record selected in form 1. The form 1 lists all the Document...
2
by: morangriffin | last post by:
Hi, New at VB6, I would like to know how to have a form open upon running the VB6 and layer to the front of the forms, Thanks Greg
1
by: Captdreamer | last post by:
Hi there, As it will be very apparent in a moment, I am very new to Access and learning on the fly. (Much fun, but frustrating at the same time) I currently am trying to get a Combo Box that I...
3
by: godhulirbalaka | last post by:
Dear Sir/Madam, I am new vb 6.0 user. I am developing Shop Management Program. I have a main form with buttons and menus. when i click any button then respective form is open. I want to set a...
1
by: Nagel Oxles | last post by:
My form has has seven Text Boxes to receive user input. Users fall into either of two categories, Current and New. 'Command_Button_New' changes the visible property of four text Boxes and their...
1
Alireza355
by: Alireza355 | last post by:
Dear all, Is there any way to say if a user of the front-end of a given database has a specific form "open"? Thanx a lot...
9
Microblitz
by: Microblitz | last post by:
Two weeks (Well about 8 hours actually) into writing VBA code and I've run up against a problem. This is the senario; ---- I have a "Main" form in which an entry on a drop down selects one of...
1
by: Eddie Z | last post by:
I'm trying to make a dialog box pop up and ask the User for their name when they open a particular form. I then want to set the default value of a text box called "EnteredBy" to their name. However...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.