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

record selector

29
I have a calendar entering a date into a text box. what i want to do is have that date search for a record with the same date and if it finds it go to that record. if it does not find that date in any records then start a new record with that date. please help :)

thanks
Jan 13 '09 #1
17 3523
ChipR
1,287 Expert 1GB
If you are using 2007, the automatic little calendar that pops up when you are in a text box set as date doesn't trigger an update event when a date is selected. So just make a "Find" or "Go" button the user can click after they enter a date.

Then in Button_Click() do

Expand|Select|Wrap|Line Numbers
  1.  
  2.         Set rs = Me.RecordsetClone
  3.         rs.FindFirst "NameOfDateFieldInTable = #" & txtDateBoxNameOnForm & "#"
  4.         If Not rs.EOF Then                'if one was found
  5.             Me.Bookmark = rs.Bookmark    'move to it
  6.         Else
  7.             'move to a new record, I don't remember the syntax at the moment
  8.         End If
  9.  
Jan 13 '09 #2
frys
29
saddly i am on Access 2003
Jan 13 '09 #3
ChipR
1,287 Expert 1GB
That's ok, it works the same way. You have a module that makes a calendar for you when you click the button right? That just means that you can trigger this code at the end of that button's code, or with a new button. I'm assuming that your form is based on the recordset you want to move around in, which would mean you probably have the text box in the form's header or footer. Is that right?
Jan 13 '09 #4
NeoPa
32,556 Expert Mod 16PB
@ChipR
Try out the following for that :
Expand|Select|Wrap|Line Numbers
  1. DoCmd.GoToRecord Record:=acNewRec
Jan 14 '09 #5
frys
29
This is beautiful thanks.. oly difficulty im running in to is that when a date is not found it is going to the very first record. not sure why


Expand|Select|Wrap|Line Numbers
  1. DoCmd.GoToRecord Record:=acNewRec
Isn't working

Expand|Select|Wrap|Line Numbers
  1. DoCmd.GoToRecord , , acNewRec
also is not working ..

perhaps i am missing some syntax
Jan 14 '09 #6
ChipR
1,287 Expert 1GB
DoCmd.GoToRecord definitely works for me. Is your form's Data set to Allow Additions?
Jan 14 '09 #7
frys
29
It is

i am unsure what to say. everything else works like a charm

i have the form set up as such

Main Form
Date_ID Auto number (which thinking about is redundant since there can only be 1 record per day)
Date Date/time (indexed(no dups))

Sub form

Meetings_ID Autonumber (identifies the meeting that was held)

Sub Sub Form
attendance_ID Number (this is linked to a relationship identifing each employee at the meeting)


But i cannot get it to jump to a new record
Jan 14 '09 #8
ChipR
1,287 Expert 1GB
I can get the same effect from
Expand|Select|Wrap|Line Numbers
  1. DoCmd.GoToRecord , , acLast
  2. DoCmd.GoToRecord , , acNext
but I doubt it will work for you if acNewRec doesn't.
Can you add a record manually with this form?
Jan 14 '09 #9
frys
29
yep manually works fine

I have trialled taking the "else"statement out completely and it does the same thing..

its as if it is skipping the docmd. line all together


when i take out this "Not"

in the line

If not rs.eof then

well obviously it doesn't find anything. but goes to a new record
Jan 14 '09 #10
ChipR
1,287 Expert 1GB
Well I didn't know that it would do that but if that is the case you could drop the whole If statement and just say Me.bookmark = Rs.bookmark.
Then, if it did find a record it would go to it, and otherwise it goes to a new one?
Jan 14 '09 #11
frys
29
that is a giant negative..

this is frustrating i have rewrote the statement or tried to 10 times..

Granted im learning the syntax as i go but it makes sence to me


if you fond this go to it

if not go to a new record... not that hard if you ask me ,,, i just cant wrap my head around it
Jan 14 '09 #12
frys
29
ok i figured it out

i think

the code was right except 1 part

Expand|Select|Wrap|Line Numbers
  1. Set rs = Me.RecordsetClone
  2.         rs.FindFirst "NameOfDateFieldInTable = #" & txtDateBoxNameOnForm & "#"
  3.         If Not rs.nomatch Then                'if one was found
  4.             docmd.gotorecord,,ac newrec
  5.         Else
  6.             Me.Bookmark = rs.Bookmark    'move to it
  7.         End If
  8.  
I highlighted the nomatch basiclly the rs.eof was saying yes there was a date.. so it the argument was true

the rs.nomatch says if there is no match go to new record else go the the record that matches
Jan 14 '09 #13
NeoPa
32,556 Expert Mod 16PB
@frys
Let me just clarify this.

Are you now saying that it was never the case that the code itself (as shown) didn't work, but simply the code that it was within never allowed it to be tested (Like Chip I was very surprised at your statement that it didn't work for you.)?
Jan 15 '09 #14
frys
29
the problem lies in the

Expand|Select|Wrap|Line Numbers
  1.  if not rs.eof then
this statement says if there is no date then... but clearly there is a date in the table. so it returns true.. after that it didn't know where to go

i simply rewrote it to say
Expand|Select|Wrap|Line Numbers
  1.  if rs.nomatch then 
  2. docmd.gotorecord,,ac newrec
  3.         Else
  4.             Me.Bookmark = rs.Bookmark    'move to it 
saying while looking in my table if there is no match go to a new record. But, if a record is found go to it.
Jan 15 '09 #15
ChipR
1,287 Expert 1GB
Well, I was thinking that if the FindFirst failed to find anything, the recordset was left with the position eof, but I just realized the only place I used that in my code was where it could never fail to find something. Everywhere else I used If Not rs.NoMatch. Sorry for misleading you, and thanks for the heads up!
Jan 15 '09 #16
NeoPa
32,556 Expert Mod 16PB
I'm getting a little confused here :S

My last question (post #14) was directed at frys (in response to the quoted comment) as I felt they had expressed themselves quite unclearly and the confusion could do with being cleared up (an answer would be appreciated). I will assume my understanding is correct unless I hear otherwise, but others finding this thread may easily be confused reading it the way it stands.
Jan 15 '09 #17
frys
29
@NeoPa

sorry .. yes you are right .. it was never the code that was incorrect
Expand|Select|Wrap|Line Numbers
  1. DoCmd.GoToRecord Record:=acNewRec
but rather the code that it was in

sorry i confuse myself at times
Jan 16 '09 #18

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

Similar topics

5
by: deko | last post by:
I have a subform datasheet that contains a full year of records sorted by a date field. I'm trying to programmatically move the record selector on the datasheet to the first record that matches a...
5
by: Mary Litten | last post by:
Hi - (This is my very first post) I have gotten to this point of registering to post because I have been spinning my wheels so long, I believe I am all caught up in the weeds. (and mud) I have...
6
by: Megan | last post by:
I'm using an unbound combo box on a form as a record selector. I'm using the combo box to choose certain types of music, i.e. Alternative, Pop, Rock, etc…and then run a report based on the...
7
by: Megan | last post by:
Hi everybody- I inherited a database that somehow uses a bound combo box as a record selector. Let me give you some background. The form is based on data from 2 tables. The first table, Person,...
1
by: Gt394 | last post by:
I have the following tables. tbl_customer CustID Primary key Custname Custaddr tbl_Quote QuoteNo Primary key ProjectName
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
1
by: wheel | last post by:
I have been ok with optimistic locking most of the time but I have a situation now where there is more of a chance that users could try to edit a record at the same time. I'd like to use pessimitic...
5
by: campbellbrian2001 | last post by:
I'm trying to get the "Carry data over to new record" code to work from Allen Browne's site: http://allenbrowne.com/ser-24.html I follwed the instruction explicitly and somethings not working......
1
by: ConfusedMay | last post by:
Hi, I'm working on a database that has a form which hold all of our products testing. each product can hold more than 1 complete test (complete test here means that product has to have before and...
10
by: jschmidt | last post by:
All, I am trying to have something happen on a form whenever the record selectors are clicked. This is access 2003. I tried the form's click event and that does not work at all. Anyone know...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.