Solved Simple and stupid question..

mloucel

Member
Local time
Yesterday, 16:20
Joined
Aug 5, 2020
Messages
356
I can see the smiles in many of you, but I just can't figure out what to do....
The problem:
I have a form, and I have a specific record I need to retrieve, I am 100% sure of the ID of the record, I don't need to search 100's of records and display them, that was done already, this particular form requires the EU [End User] to know exactly the ID, enter that ID, click "Retrieve Record" and simply check if the typed number is correct (EU can make a mistake) and display the record so they can edit that specific record, of course if they made a mistake display "Record not found please correct".

So the form must start as a blank form no data whatsoever.
EU enters the ID, clicks the button and either he finds the record or displays a message.
if found
the EU can make changes to the record except the ID

Is that simple, but I have tried a few things and my brain is completely washed, incredible that the most easiest of the tasks I cannot do while some more complex I was able to find a solution.

I created a DEMO database that I've been playing with, but in a frustration moment I delete the damn thing, so I rebuild enter some bogus data with hope that someone can guide me towards the right way to do what I want.

Sorry if this is confusing I cannot believe myself.

Thanks for your help.

Maurice.

PS/ In this demo table the ID I know and I use to search is called Emp_ID so that will be the only field the EU cannot edit.
 

Attachments

The Code:-

Code:
Option Compare Database
Option Explicit

Private Sub btnRetrieveRec_Click()
    Me.RecordSource = "SELECT * FROM DemoTable WHERE Emp_ID=" & Chr(34) & Me.txtGetID & Chr(34)
        If Me.RecordsetClone.EOF Then
            MsgBox " >>> " & "The ID > " & Me.txtGetID & " < Entered is Incorrect Please Check & Enter it Again"
        End If
End Sub      'btnRetrieveRec_Click
 
Last edited:
Dam ArnelGP you beat me to it!!!
Thanks same concept as Arnel, but diff method
The Code:-

Code:
Option Compare Database
Option Explicit

Private Sub btnRetrieveRec_Click()
    Me.RecordSource = "SELECT * FROM DemoTable WHERE Emp_ID=" & Chr(34) & Me.txtGetID & Chr(34)
        If Me.RecordsetClone.EOF Then
            MsgBox " >>> " & "The ID > " & Me.txtGetID & " < Entered is Incorrect Please Check & Enter it Again"
        End If
End Sub      'btnRetrieveRec_Click
That is sot of what I was doing, I can see on your code my mistake, but I like Arnel's alternative, specially the use of NEW REC to display a blank screen, thanks, I do appreciate your input.
 
you can also use combo, so EU can make small mistake.
see frm_retrieve2:
 

Attachments

you can also use combo, so EU can make small mistake.
see frm_retrieve2:
yes I see your point but imagine the database with 3000 names, combo won't work, I have a question thou, how do I stop the EU to make any type of modification to the Emp_ID once they start editing the record, I don't want that specific field to be changed, that'll mess up the whole database.
I've tried
me!emp_ID.locked=true
me.Emp_ID.locked=true
and I always get an error
of couse I have to enable that again once I call LockIt().

Why that doesn't work for me?

Thanks Arnel
 
the emp_id won't get modified, the textbox is unbound.
making changes to this textbox is another candidate for
a search parameter.
 

Users who are viewing this thread

Back
Top Bottom