Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8028285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:05:37+00:00 2026-06-05T00:05:37+00:00

I am searching for records that have the start date: [userinput], if it has

  • 0

I am searching for records that have the start date: [userinput], if it has any matches, that record will be displayed, the issue is that the nature of my program it is neccesary for ALL matches (there can be multiple on the same day) need to be somehow displayed.

This is what I have so far:

     public void searchDay() {
    String idInputString  = JOptionPane.showInputDialog(null, "Please enter the Date you're searching for:");


       try {   
            for (int i = 0; i < orderID.length; i++) {
                if (idInputString.equals(startDate[i])) {

                    txtOrderID.setText(orderID[i]);
                    txtOrderForename.setText(customerForename[i]);
                    txtOrderSurname.setText(customerSurname[i]);

                    txtOrderAddress1.setText(address1[i]);
                    txtOrderAddress2.setText(address2[i]);
                    txtOrderTown.setText(town[i]);
                    txtOrderCounty.setText(county[i]);
                    txtOrderPost.setText(postCode[i]);
                    txtOrderCarModel.setText(carModel[i]);

                    txtOrderCarReg.setText(carReg[i]);
                    txtOrderStartDate.setText(startDate[i]);
                    txtOrderStartTime.setText(startTime[i]);

                    txtOrderSerial.setText(serialNum[i]);

                } else {
                    JOptionPane.showMessageDialog(null, "Order ID Doesn't Exist", "Error!", JOptionPane.WARNING_MESSAGE);
                    break;
                }

            }

      } catch (Exception e) { 
       JOptionPane.showMessageDialog(null, "Order ID Doesn't Exist", "Error!", JOptionPane.WARNING_MESSAGE);
       initFields();

   }
}     

I get errors even when typing in a date I know exists.

I think the problem lies with the for loop. It counts the number of elements, not total records.

This is stored in “numberOfOrdersInArray” int variable.

But if I do:

     for (int i = 0; i < numberOfOrdersInArray.length; i++) {

I get the error ‘int cannot be dereferenced’

I hope I explained my problem well enough,

Many thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:05:40+00:00Added an answer on June 5, 2026 at 12:05 am

    Use .equals() for string comparison not ==. == checks against references, while .equals() actually compares the string characters. This is important.

    EDIT:

    //instead of a count, you could also use a boolean
    for (int i = 0, count= 0; i < orderID.length; i++) {
                    if (idInputString.equals(startDate[i])) {
    
                        txtOrderID.setText(orderID[i]);
                        txtOrderForename.setText(customerForename[i]);
                        txtOrderSurname.setText(customerSurname[i]);
    
                        txtOrderAddress1.setText(address1[i]);
                        txtOrderAddress2.setText(address2[i]);
                        txtOrderTown.setText(town[i]);
                        txtOrderCounty.setText(county[i]);
                        txtOrderPost.setText(postCode[i]);
                        txtOrderCarModel.setText(carModel[i]);
    
                        txtOrderCarReg.setText(carReg[i]);
                        txtOrderStartDate.setText(startDate[i]);
                        txtOrderStartTime.setText(startTime[i]);
    
                        txtOrderSerial.setText(serialNum[i]);
                        count++;
                    } 
                    if(i == orderID.length - 1 && count==0){
                        JOptionPane.showMessageDialog(null, "Order ID Doesn't Exist", "Error!", JOptionPane.WARNING_MESSAGE);
                        break;
                    }
    
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have users searching records of type Record. They type a search term in
I have a search page that is tasked with searching 3.5 million records for
Let's say I have records in a MySQL table that have a unix timestamp
I need to build an app. that will record video from the webcam, show
I have an application that will store and track visitors. These visitors are created
I've tested a weird query that involves me searching for non-existent records. In a
I have a table of records, which has a self-relationship. Additionally - to make
I have in a viewport a textfield that it is for searching purpose. I
i have an iphone application that use core data for searching ,and in similar
I am searching for records in a table as follows: SELECT Id, Name FROM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.