473,402 Members | 2,050 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,402 software developers and data experts.

i cant pass the value from table to textbox through dlookup

I dont know why I cant pass the value of AccountType (from TblAccount) to Me.txtWAccounType(textbox from WithdrawView)

pls help me.. here's my code

Expand|Select|Wrap|Line Numbers
  1.  If IsNull(DLookup("[AccountId]", "TblAccount", "AccountId = '" & txtWAccountId & "'")) Then
  2.  MsgBox "Account Number Doesn't Exist"
  3.  
  4.  Else
  5.  Me.txtWAccounType.Value = DLookup("[AccountType]", "TblAccount", "AccountId = ' " & Forms![WithdrawView]![txtWAccountId] & "' ")
  6.  MsgBox "Account Number Do Exist"
  7.  
  8.  End If
  9.  
my goal is to retrieve that AfterUpdate of AccountId. messagebox"Account Number Do Exist" pop up so it means there is a value but why it doesn't appear in Me.txtWAccounType.

pls help.. thank you.
Oct 10 '12 #1

✓ answered by Seth Schrock

Lets see if I can narrow down where the problem is. Above the code that you posted, put in the following:

Expand|Select|Wrap|Line Numbers
  1. Dim strResult as String
  2. strResult = DLookup("AccountID", "TblAccount", "AccountID =" & txtWAccountID)
Then, in line 5 of what you posted, replace the DLookup... with strResult.

Now click in the gray area next to that line of code (while in the VBA editor). A red dot should appear. Now do whatever is required to make your code execute. The code will stop at the line with the red dot. Now press Ctrl+G to make the Immediate window appear. Type into the immediate window
Expand|Select|Wrap|Line Numbers
  1. ? strResult
What do you get?

11 1502
Seth Schrock
2,965 Expert 2GB
Something that I just noticed is that in line 5, it looks like you left out a T in Me.txtWAccounType. Just a guess. If that fixes it, then you can ignore the rest of this post.

Your DLookup should be like this:

Expand|Select|Wrap|Line Numbers
  1. DLookup("AccountID", "TblAccount", "AccountID =" & txtWAccountID)
The name AccountID makes me think that the value is a number, in which case you don't want the ' surrounding it. Also, in line 5, I'm assuming that the active form is WithdrawView since in line 1 you left off the Forms!WithdrawView! before the control name. If I'm wrong, then you would need to add it back on to the code that I posted. Also in line 5, you don't need the .Value. All you need is
Expand|Select|Wrap|Line Numbers
  1. Me.txtWAccounType = ...
Oct 10 '12 #2
Thank you. I did your suggestion but the textbox value is still null. I didn't get any error message and the messagebox"Account Number Do Exist" only proves that there is a value found but why it doesn't appear on my textbox? anyway AccountID is a string
example : 20091S

Thank you so much..
Oct 10 '12 #3
Seth Schrock
2,965 Expert 2GB
Lets see if I can narrow down where the problem is. Above the code that you posted, put in the following:

Expand|Select|Wrap|Line Numbers
  1. Dim strResult as String
  2. strResult = DLookup("AccountID", "TblAccount", "AccountID =" & txtWAccountID)
Then, in line 5 of what you posted, replace the DLookup... with strResult.

Now click in the gray area next to that line of code (while in the VBA editor). A red dot should appear. Now do whatever is required to make your code execute. The code will stop at the line with the red dot. Now press Ctrl+G to make the Immediate window appear. Type into the immediate window
Expand|Select|Wrap|Line Numbers
  1. ? strResult
What do you get?
Oct 10 '12 #4
Sir Do you have other suggestion on how can i get table field value and put it in the textbox (as a part of searching the record) where the values to be inserted on the textbox depends upon the AccountID?
thank you so much..
Oct 10 '12 #5
twinnyfo
3,653 Expert Mod 2GB
Rheigny,

Are txtWAccountId and Forms![WithdrawView]![txtWAccountId] supposed to be the same control on the same form? If so, then your code could look like this:

Expand|Select|Wrap|Line Numbers
  1. If IsNull(DLookup("[AccountId]", "TblAccount", "AccountId = '" & Me.txtWAccountId & "'")) Then 
  2.     MsgBox "Account Number Doesn't Exist" 
  3.  
  4. Else 
  5.     Me.txtWAccounType.Value = DLookup("[AccountType]", "TblAccount", "AccountId = ' " & Me.txtWAccountId & "'")
  6.     MsgBox "Account Number Do Exist" 
  7. End If
Syntax for references to forms must be pretty exact....
Oct 10 '12 #6
There's an error now after i did your suggestion its
Run-time error "3075":
Syntax error (missing operator) in query expression 'AccountID = 20091S'

and highlight this

Expand|Select|Wrap|Line Numbers
  1. strResult = DLookup("AccountID", "TblAccount", "AccountID =" & txtWAccountId)
Oct 10 '12 #7
? strResult
20091S

Here's what I get from immediate window sir.
Oct 10 '12 #8
twinnyfo
3,653 Expert Mod 2GB
You forgot the single quote to designate a String...

Expand|Select|Wrap|Line Numbers
  1. strResult = DLookup("AccountID", "TblAccount", "AccountID ='" & txtWAccountId & "'")
Oct 10 '12 #9
Wow sir It's working! Thank you so much!
Oct 10 '12 #10
twinnyfo
3,653 Expert Mod 2GB
My pleasure! Glad we could assist you today!
Oct 10 '12 #11
Thank you so much again!
Oct 10 '12 #12

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

Similar topics

5
by: velu | last post by:
Problem in getting value from textbox & radiobuttonlist to a valuable inside a datagid. I want to insert a record into a table thru datagrid. Here is the code (see below) Private Sub...
2
by: Mark | last post by:
Hello - From an Access VBA module, I'm trying to pass a Table to a VB.Net class. I'm getting the following error running the VBA: "Unable to cast object of type System._ComObject to type...
1
by: rudranee | last post by:
Hi everyone, I want to know how can i edit a value in textbox in html . I have a field where I have already put a value from database but i also want to edit it . for example ,if in a textbox i...
3
by: startsmart | last post by:
Hi This is first time to write and alse it is first time to show this site my problem is i need to pass value from any input type like text for example to hidden field I tried to make a...
6
by: Chris | last post by:
I created a very simple web page in asp.net. there are only a textbox and a button on the page. when the page loads into web browser there is current date in the textbox. but the date can be...
1
by: colleen1980 | last post by:
Hi: Can any one please tell me that how to i pass the two textbox values in the new page. If i use the form action in the popup window page then the new page is open in the same popup window as i...
1
by: abirami elango | last post by:
Hi, i have created a web application in vb.net. i have assigned a value to the textbox during page UNLOAD event as below.. ......... Protected Sub Page_Unload(ByVal sender As Object, ByVal e As...
1
by: adepvivek | last post by:
Hi everybody, I am using textbox in gridview as template. And I want to stored the value of textbox. For that I want to pass the textbox value to stored procedure. So please give me solution.
66
by: happyse27 | last post by:
Hi All, my html code is sno 1) and perl code is sno 2). a) I tried to print $filename and it cant print out the value, only blank was displayed, and the file could not be uploaded. And it...
1
by: ajax.sam | last post by:
hi all, i got 2 questions! i want to do these: 1. select @col1 from some_table where <some_conditions>; I can pass parameters by using Parameters.Add for <some_conditionsbut not for the @col1....
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: 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: 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.