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

Open a form to search for a record using a command button which prompts input box

64
Are this the correct coding for if else statement for the input box?
Can help me?

Expand|Select|Wrap|Line Numbers
  1. Dim Search As String, Message As String
  2. Search = "Find RF"
  3. Message = InputBox(Prompt, "Search")
  4. If Message <> RF_NO Then
  5. MsgBox "Data not exist"
  6. Else
  7. DoCmd.OpenForm "Product_Requisition", acNormal, , "[RF_no] Like '" & Message & "*'"
  8. MsgBox "Data exist"
  9. End If
Feb 26 '15 #1
5 1161
twinnyfo
3,653 Expert Mod 2GB
mrijet,

It is unclear from your code what "RF_NO" is. It seems to be listed as a variable, but it is neither declared nor set anywhere to say what it is.

If it is a control on a Form, then your code will only check to see if the input value matches what is currently displayed on your form, but will not "find" any record for you.

All that aside, if you were to delete lines 4-6 and line 9, the command to open a form "should" work, assuming all field names are correct.
Feb 27 '15 #2
mrijet
64
Actually I choose to make a condition such as if I put the RF_no, they will find me the RF_no that exist for me..and if the RF_no did not exist it will show message box to me that show the data not exist...

So, did the coding I sent it was correct or not...or maybe you can help me? mrtwinnyfo
Mar 11 '15 #3
twinnyfo
3,653 Expert Mod 2GB
Again,

You have to help us out here. Your code provided does not tell us anything about what is going on. Is the Form Bound? We still don't know if RF_No is a variable or a control on a form or an underlying field in a table (we assume from one of your other posts that it is a field name).

However, without this information, it is difficult to guide to a solution. Standing by to assist as necessary.....
Mar 11 '15 #4
mrijet
64
Expand|Select|Wrap|Line Numbers
  1. Dim lngID As String
  2.  
  3. lngID = InputBox("Enter RF No")
  4. If lngID = "" Then
  5. DoCmd.ClearMacroError
  6. Else
  7. DoCmd.OpenReport "Requisition_ReportComplete", acViewReport, , "[RF_no]=" & lngID
  8. End If
As you see the code above is for searching specific data and it's actually can work without any error..

But if I add this coding....

Expand|Select|Wrap|Line Numbers
  1. Dim lngID As String
  2.  
  3. lngID = InputBox("Enter RF No")
  4. If lngID = "" Then
  5. DoCmd.ClearMacroError
  6. ElseIf lngID <> RF_no Then
  7. MsgBox "Data not exist"
  8. Else
  9. DoCmd.OpenReport "Requisition_ReportComplete", acViewReport, , "[RF_no]=" & lngID
  10. End If
And put none exist data it will not go the coding that I bold it...
Can help me?

mr twinnyfo
Mar 12 '15 #5
twinnyfo
3,653 Expert Mod 2GB
Please answer the questions of Post #4 and I can guide you toward a solution.
Mar 12 '15 #6

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

Similar topics

5
by: dgrabuloff | last post by:
i am inputting records using a form. how do i put a command button on the form that will copy the record i just input----sometimes i have the same record that needs to be put in 3 or 4 times and i...
4
by: Steven | last post by:
Hi, Would need some thought about using a button of the existing form to search record before deleting it. Any quick help is very appreciated. Steve
4
by: sirimanna | last post by:
hi, Is any one can help me to open files in my computer(for an example: some word document)using command button... i want to open file's using my vb programme..but i can't do it...can any one...
2
by: tejavenkat | last post by:
Hi, I have one scenario i.e Download as csv is there it is a command button when we click on this the save dialog box should be open,Am using javascript how can we do this by using by javascrpt...
4
beacon
by: beacon | last post by:
Hi everybody, I have a main form, frmDeficiency, that has a tab control, deficiencyTabControl, that has a subform, fsubEpisodeDetail, on page 2 of the tab control. I also have a command button...
1
by: Palaniappan | last post by:
how to add an item into the textbox by using command button in ms access in the form from the table?
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.