DoCmd

DaronSpicher

New Member
Joined
Jan 20, 2003
Messages
2
Hi,

I'm wanting to search for a record based on the string BarCodeInput. If I find a record, I want to do one thing. If not found, I want to pop that table open so i can enter one using

DoCmd.OpenTable "MainDataBase"

I am trying to do this by using:

DoCmd.FindRecord(BarCodeInput, , True, , True)
How do I key off of that and go one way or the other? Does it return a boolean as found somehow? Does it return a record number that I can check against and if it is null or zero I would know?

Any thoughts?

Thanks! -Daron
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
On 2003-01-21 22:26, DaronSpicher wrote:
Hi,

I'm wanting to search for a record based on the string BarCodeInput. If I find a record, I want to do one thing. If not found, I want to pop that table open so i can enter one using

DoCmd.OpenTable "MainDataBase"

I am trying to do this by using:

DoCmd.FindRecord(BarCodeInput, , True, , True)
How do I key off of that and go one way or the other? Does it return a boolean as found somehow? Does it return a record number that I can check against and if it is null or zero I would know?

Any thoughts?

Thanks! -Daron

Hi Daron, FindRecord moves focus to that record if you were in a form for example. If a match wasnt found it just stays on the current record.

When Ive used this I check that if the value Im searching for is the same as the current record, then it must have found what I was looking for.

example:
Code:
SearchBox = Me.txtGotoRecord
Ctl1!Code.SetFocus
DoCmd.FindRecord SearchBox, acEntire, False, acSearchAll, True, acCurrent, True

'Determine search result
    Ctl1!Code.SetFocus
    If Ctl1!Code.Value <> Val(SearchBox) Then
    MsgBox "The Record you searched for was not found", vbInformation, "Project Record Not Found"
    Me.txtGotoRecord.SetFocus
    Exit Sub
    End If

Do you want to do something to a record in a table or find a record on a form? Sounds like you want to create a record if not found or at least open form in a new record. Could you clarify what you want.
 
Upvote 0
Hi Darron, I see your other post now so I believe I know what you want. I think to do this you need to create a recordset then use Seek or FindFirst to locate the record in the inventory table, then use those values to make a new record in the Load table.

Im not all that familiar with creating recordsets in code but Im going to have a go at it and i'll post back when i've got something that works :)
 
Upvote 0
Wahoo I think I successfully created my first recordset. The code is in your other posting (seemed more apt). :)
 
Upvote 0

Forum statistics

Threads
1,221,507
Messages
6,160,219
Members
451,631
Latest member
coffiajoseph

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top