473,387 Members | 1,492 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.

make sure data is entered before going to new form?

AccessIdiot
493 256MB
Like your mother-in-law that visits too often, I am back. :-)

I have two tables, two forms. The primary key of table 1 is a foreign key in table two. I have a button on form one that opens form two and it should take the ID autonumber field from the first form and populate the ID field on the second form (and get stored in the table too).

But it's not working. My guess is that technically the data from the first form hasn't populated the database yet so it can't get carried over to form two.

So how do I tell Access that when I click the button to open up form two, go ahead and stick all the data that was entered on form one into the database (but you don't have to go to a new record, just stay put while form two is being filled out - eventually it will be closed).

Is it like a requery or refresh or something like that?

thanks to any and all help,
melissa :-)
Mar 23 '07 #1
129 9020
Denburt
1,356 Expert 1GB
A little tired (feeling brain dead) this should work but I know there is a better way.

Expand|Select|Wrap|Line Numbers
  1. if me.dirty then
  2. MyBookMark = Me.Bookmark
  3. Me.Requery
  4. Me.Bookmark = MyBookMark
  5. end if
  6.  
Mar 23 '07 #2
AccessIdiot
493 256MB
Denburt to my rescue again. :-)

Okay I think I know that dirty is when you have data on a form that hasn't been entered yet right? But what is bookmark?
Mar 23 '07 #3
Denburt
1,356 Expert 1GB
It is what it says it is lol. ;) A bookmark merely marks your position so that after you requery the form you can return to your current location. If you have 6 records but your editing record 2 then after you requery thats where you will return the second record. :) You can use that in your recordsets and such or maybe synchronize between a recordsetclone and your form (maybe you searched the recordset found your record now want to display it).

me.bookmark = rs.bookmark
Mar 23 '07 #4
Denburt
1,356 Expert 1GB
Im not sure if you know this so I thought I would toss it out there. If you highlight a word in VBA and press F1 you will get the help file on that word (if it exists in the helpfile). I don't mind answering your questions though, I know it is usually easier to understand plain english than some of the helpfiles.
Mar 23 '07 #5
AccessIdiot
493 256MB
Okay I'm sure that works great but maybe that isn't what is going on with my project. :-) Somehow I knew it couldn't be that simple.

Basically I have an autonumber field called Replicate_ID that lives in the Replicate table. It is tied in a one to many relationship to the Specimen table. Basically one replicate can have many specimens. So on the Replicate form (subform actually, that you helped me with enabling) there is a button for "add specimen information". Click on the button and it opens the Specimen table. When I start typing info into the Specimen form (which feeds the Specimen table). I expect to see the Replicate ID field populate but it doesn't. The control source is set to tbl_replicate.replicateID (as opposed to tbl_specimen.replicateID).

Since the two are linked in a one to many it should auto populate right? That's why I suspected it wasn't getting into the replicate table.

Any clue what I'm doing wrong?

And yeah, I knew about F1 but I at first thought bookmark referred to a fieldname or control name on one of your projects. :-) That'll show me. And yeah, the help is sometimes no help and at best somewhat confusing. I like real world discussion and examples I find on this forum.
Mar 23 '07 #6
Denburt
1,356 Expert 1GB
O.K. If I understand this then, ReplicateID will not auto populate in the specimen table right? Well its not supposed to it does in the Replicate Table because it is Autonumber but in the Specimen table you still need to choose 1 (or set a default value) and you can't add one to the replicate table from the specimen table (if thats the problem we may want to look at your relationships).

And yeah, I knew about F1 but I at first thought bookmark referred to a fieldname or control name on one of your projects. :-)
FYI you will or shouldn't EVER see me use a regular word for a field. I try and maintain a strict policy about that. The problem is that if I named a field BookMark and then tried to use it, well it could get nasty ya know. I have watched so many people use Date for a field name as an example... Date() is a function to retrieve todays date. I will usually use PurchDate or something to that effect It is also more relevant since I am using that for a purchase date. just something to keep in mind.
Mar 23 '07 #7
AccessIdiot
493 256MB
No, sorry, I don't mean autoincrement. I meant that since they are tied together in a one to many relationship I would just expect to see the value from one form appear on the other form.

Isnt' that how it works when two fields are tied together? If you set Customers.CustomerID = 5 on a form, and then while in that record you open up the Orders form, then shouldn't Orders.CustomerID = 5? Kind of like a subform within a form?

I also tried sending the value via OpenArgs but that failed too.

I'm sure it's something fundamental that I'm just not seeing and will smack my forehead when its explained to me.
Mar 23 '07 #8
Denburt
1,356 Expert 1GB
Yeah your right take a look at your main form in design view (I think I got ya) click the control that is holding your subfom not the form itself then view the properties. You should see:

Link Child Fields
Link Master Fields

Place your Replicate_ID in both places Child Field would be the subform master well you get it.

Is that the issue at hand?
Mar 23 '07 #9
AccessIdiot
493 256MB
Yeah your right take a look at your main form in design view (I think I got ya) click the control that is holding your subfom not the form itself then view the properties. You should see:

Link Child Fields
Link Master Fields

Place your Replicate_ID in both places Child Field would be the subform master well you get it.

Is that the issue at hand?
lol kind of. I was using the form/subform analogy to point out how I think it should work. It works great on a form to subform level but how to make it work from one form to another? (or from a subform to a completely different form).

The button is on the subform, it launches a completely new and different form, and I want the primary key of the table that the subform feeds to appear on the new form (and get entered into the table underlaying the new form).

To use the same analogy as above, if the Customers form was actually a subform but there was a button to launch the Orders form I would want the CustomerID on the Customers subform to show up on the Orders form and get entered into the Orders table (where Customers.CustomerID = Orders.CustomerID).

Am I talking the same thing you are and just not getting it? I tend to do that a lot.

*edit* oh and do you have to have the field physically on the subform/form for it to work? I mean, the ID field gets populated even if you don't see it simply by being a new record. I'm just trying to associate my Specimen(s) with a particular ReplicateID.
Mar 23 '07 #10
Denburt
1,356 Expert 1GB
Gotcha when you open the new form I presume you are using Docmd.openform?
If so add your ID to the openargs like so Docmd.OpenForm ,,,,,,me!Replicate_ID
Then in the form that pops up go into the onOpen event and you can add the following.
Expand|Select|Wrap|Line Numbers
  1.     If not IsNull(Me.OpenArgs) Then
  2.          me!Replicate_ID = Me.OpenArgs
  3.     End if
  4.  
You may need the fields to be on the forms if so just set visible to no and your good.
:)
Mar 23 '07 #11
AccessIdiot
493 256MB
Hey there,

I'm getting an error message: "You can't assign a value to this object" for that code. :-(

Any idea why?
Mar 26 '07 #12
AccessIdiot
493 256MB
Nope, wait, it does work but only if I leave the recipient textbox unbound. I need to get the value transferred through OpenArgs into the 2nd table.

In other words, I have ReplicateID transferred over to the form but I need to get it into the Specimen table (where Replicate.ReplicateID = Specimen.ReplicateID).
Mar 26 '07 #13
AccessIdiot
493 256MB
Still can't figure this one out. How do I assign the value passed by OpenArgs to the value in the table?

Thank for any help!
Mar 26 '07 #14
Denburt
1,356 Expert 1GB
Try to update it manually can you do that?
Mar 26 '07 #15
AccessIdiot
493 256MB
What do you mean? :-)
Mar 26 '07 #16
Denburt
1,356 Expert 1GB
On your form see if you can enter the information from the first form (the info you want carried to the second form) into the field using the keyboard.
Mar 26 '07 #17
AccessIdiot
493 256MB
Well, I'm hoping to make the field invisible, so I need it to be filled in automatically.

Essentially, I just need to tell Access that when I click on the button to start adding Specimen information that they are all tied to that one Replicate. So no matter how many Specimens I create with the Specimen form, the same Replicate ID is going into the Specimen table.
Mar 26 '07 #18
Denburt
1,356 Expert 1GB
Well, I'm hoping to make the field invisible, so I need it to be filled in automatically.

Essentially, I just need to tell Access that when I click on the button to start adding Specimen information that they are all tied to that one Replicate. So no matter how many Specimens I create with the Specimen form, the same Replicate ID is going into the Specimen table.
I understand however for troubleshooting purposes... Make it visible and see if it is updateable (humor me) :) If not then check the underlying recordsource and see if it is updateable in there.
Mar 26 '07 #19
AccessIdiot
493 256MB
I'm sorry, I'm a little lost here. If I pass the value using OpenArgs in the DoCmd.OpenForm then it passes successfully to an unbound textbox.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)               'Pass replicate id when form opens
  2. If Not IsNull(Me.OpenArgs) Then
  3.          Me.txt_ReplicateID = Me.OpenArgs
  4.     End If
  5. End Sub
But it doesn't get into the database because it is an unbound textbox.

If I add a textbox that has a control source of tbl_Replicate.Replicate_ID then I cannot type into it because it is an autonumber field.
Mar 27 '07 #20
Denburt
1,356 Expert 1GB
Sounds like our wires are getting crossed a bit here. Lets backup,


In other words, I have ReplicateID transferred over to the form but I need to get it into the Specimen table (where Replicate.ReplicateID = Specimen.ReplicateID).
Replicate.ReplicateID sounds as though it should be the Primary Key set to autonumber.

Specimen.ReplicateID should be a Forien Key and set as a number field.

When you open the Specimen form you pass the argument in and the two tables will have a common key.
Mar 27 '07 #21
AccessIdiot
493 256MB
Yes, exactly. Except that Specimen.Replicate_ID is not getting updated and I think it's because when the form is opened the Replicate info hasn't been officially entered into it's own table, so there is no ID to pass. Does that make sense?

Essentially:
sbfrm_Replicate has Replicate.Replicate_ID.
sbfrm_Replicate has button that opens frm_Specimen
frm_Specimen has Specimen.Replicate_ID that should contain the value of Replicate.Replicate_ID but nothing is showing up.

My guess is that the data on sbfrm_Replicate hasn't gotten into the table yet so nothing is being passed.

How do I remedy this?
Mar 27 '07 #22
Denburt
1,356 Expert 1GB
The following is really derived from the old DoCmd.DoMenuItem command but more efficient.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdSelectRecord
  2. DoCmd.RunCommand acCmdSaveRecord
  3.  
:)
Mar 27 '07 #23
AccessIdiot
493 256MB
Can you explain what this does and how it is used? Does it replace current code? Do I still use the OpenArgs?

thanks!
Mar 27 '07 #24
AccessIdiot
493 256MB
So I put those two lines of code into the button code that launches the form, ahead of the DoCmd.Open command and am still getting the same error.

I checked the table though and the replicate info is going into the replicate table, just not into the specimen table.

FYI the error message I am getting is
"The Microsoft Jet database engine cannot find a record in the table 'tbl_Replicate' with key matching field(s) 'tbl_Specimen.Replicate_ID'"
Mar 27 '07 #25
Denburt
1,356 Expert 1GB
Yes, exactly. Except that Specimen.Replicate_ID is not getting updated and I think it's because when the form is opened the Replicate info hasn't been officially entered into it's own table, so there is no ID to pass. Does that make sense?
No it doesn't because earlier in the thread you stated that is would work for an unbound control and so it should work for a bound control, unless it isn't updatable such as an autonumber field, however the value would still be stored in the openargs we can test the openargs to see if it has a value using debug (see below code).

Can you explain what this does and how it is used? Does it replace current code? Do I still use the OpenArgs?

thanks!
Add this to your code before you open the new form (using your open args). This will make sure the reecord in question is saved to the table before you move on to the next form.

Try this goto the VBA window press the menu "view" then "Immediate Window" (Ctrl G for shortcut fanatics). Now do you see the window that has a title of immediate? If so then good now your code will look something like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click()
  2.  
  3. DoCmd.RunCommand acCmdSelectRecord
  4. DoCmd.RunCommand acCmdSaveRecord
  5.  
  6. 'The following line will produce any result in the immediate window for your _ review after you test the form come back here and look in the immediate _ window for your value.
  7.  
  8. Debug.print  Me!Replicate_ID
  9.  
  10. Docmd.OpenForm,,,,,,Me!Replicate_ID
  11.  
  12. End sub
  13.  
How are we doing now?

The RunCommand essentially replaces the code in the first page of this post (I mentioned me being tired should have said exhausted) my appologies it is effective but nasty.

Code to remove:
Expand|Select|Wrap|Line Numbers
  1. if me.dirty then
  2. MyBookMark = Me.Bookmark
  3. Me.Requery
  4. Me.Bookmark = MyBookMark
  5. end if
  6.  
Proper method:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdSelectRecord
  2. DoCmd.RunCommand acCmdSaveRecord
  3.  
Mar 27 '07 #26
AccessIdiot
493 256MB
No it doesn't because earlier in the thread you stated that is would work for an unbound control and so it should work for a bound control, unless it isn't updatable such as an autonumber field, however the value would still be stored in the openargs we can test the openargs to see if it has a value using debug (see below code).
Okay in the immediate window I see the number. I know it is getting passed because it does show up in the unbound textbox when I assign me.txt_ReplicateID = Me.OpenArgs.

But if I have a textbox that is bound to tbl_Replicate.Replicate_ID or tbl_Specimen.Replicate_ID on my form I do not see the number. tbl_Replicate.Replicate_ID is an autonumber PK. tbl_Specimen.Replicate_ID is a number field FK and they are tied in a one to many where one replicate can have many specimens but one specimen belongs to only one replicate.

Do I have the relationships wrong?
Mar 27 '07 #27
Denburt
1,356 Expert 1GB
Backing up a couple of posts lets try it manually, In your tbl_Specimen Form can you enter records including the tbl_Specimen.Replicate_ID field? If it is a number field you should be able to manually type in the number from the previous form. If you can then everything should work, if not then we need to look at your recordsource for that form.
Mar 27 '07 #28
AccessIdiot
493 256MB
Backing up a couple of posts lets try it manually, In your tbl_Specimen Form can you enter records including the tbl_Specimen.Replicate_ID field? If it is a number field you should be able to manually type in the number from the previous form. If you can then everything should work, if not then we need to look at your recordsource for that form.

Yes I can manually enter in the value. It barks if I enter in the wrong value. It only goes into the db if I manually enter the value. The control source is tbl_Specimen.Replicate_ID
Mar 27 '07 #29
Denburt
1,356 Expert 1GB
The control source is tbl_Specimen.Replicate_ID
And is the control name:
Replicate_ID
If so then

Me!Replicate_ID = me.openargs

Should work...
Mar 27 '07 #30
AccessIdiot
493 256MB
I have that on form load and I get an error message that I can't assign a value to the object. :-(
Mar 27 '07 #31
Denburt
1,356 Expert 1GB
Sorry I wasn't more clear that would go into the open event.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. If not IsNull(Me.OpenArgs) Then
  3.          me!Replicate_ID = Me.OpenArgs
  4. End if
  5.  
Mar 27 '07 #32
AccessIdiot
493 256MB
lol, it doesn't like that one either.
Mar 27 '07 #33
Denburt
1,356 Expert 1GB
It has to be something simple that is being overlooked. If you can add a value to that field manually then there is no reason you can't do it the way we have it in code.
Mar 27 '07 #34
AccessIdiot
493 256MB
I agree but I am at a loss as to where to look! Any ideas on what would cause the error? Is there something that is blocking the assignment that I could look into? Could it be conflicting with some other event?
Mar 27 '07 #35
NeoPa
32,556 Expert Mod 16PB
It has to be something simple that is being overlooked. If you can add a value to that field manually then there is no reason you can't do it the way we have it in code.
Yes there is. It's a timing issue.
I had a (v v) long discussion with Mary the other day about this sort of thing and it will not be allowed at that stage (OnOpen) due to the form not yet having a current record (I think). Clearly an unbound control will not have the same restrictions.

Melissa,
Can I ask how we got from using subforms - where we were a couple of weeks ago (Separate thread and including sending me a copy of the db) - to using separate forms for this? As discussed, it is much harder to implement (than doing the whole process using subforms). Not impossible, as there are some quite complex work-arounds, but possibly a bridge too far for your current stage of understanding.
BTW Master & Child linked fields (that make the whole process work so smoothly for subforms), are not available for separately called forms.

If we need to, we can get you through this but we will need to be very disciplined in our communication as we are talking some fairly convoluted concepts here and if we get out of step between ourselves then we will all just get confused (Notice the difficulty of communication within this very thread).
Mar 28 '07 #36
NeoPa
32,556 Expert Mod 16PB
In short, you need to save the current record of your existing form first before opening the new one passing the OpenArgs.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdSaveRecord
In the OnOpen event procedure you need to store the OpenArgs value.
In the OnCurrent you could do something like setting the bound control to the passed value then immediately setting the Dirty flag to False.
Check that your bound controls are properly set up though. They should not be set explicitly to a data source as the data source for all the bound controls on the form should be the datasource that the form itself is bound to.
Mar 28 '07 #37
AccessIdiot
493 256MB
In short, you need to save the current record of your existing form first before opening the new one passing the OpenArgs.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunCommand acCmdSaveRecord
In the OnOpen event procedure you need to store the OpenArgs value.
In the OnCurrent you could do something like setting the bound control to the passed value then immediately setting the Dirty flag to False.
Check that your bound controls are properly set up though. They should not be set explicitly to a data source as the data source for all the bound controls on the form should be the datasource that the form itself is bound to.
Hey NeoPa thanks for stepping in. It makes sense that timing could be an issue, I've seen the same thing in Flash.

You asked about forms and subforms - I did do that successfully but now I am onto a different table/form. To create another nested subform inside the current subform would take up too much screen space. Would it work to use tabs? I could see that happening if working with forms is too difficult.

My project has multiple forms, some are used and some are not. Here is how it is currently setup:

1) User is presented with a main menu form with buttons. User clicks a button and is taken to

2) a survey form. When they click a button on the survey form it enables

3) a replicate subform within the survey form. On the replicate subform they can click a button to enter data about specimens that were caught during the replicate. Clicking the button takes them to

4) the specimen form. If the specimen they have caught is not in the species drop down combo box they can type it in and the NotInList function will

5) open a species form.

So you see there are lots of steps and a variety of forms. Every survey will have a replicate. Not every replicate will have specimen data so it has to be optional not required. But since there can be more than one specimen per replicate the replicate id has to get into the specimen table.

I can sort of follow your suggestions on code but am a little lost on the dirty flag and not really sure what you mean by bound controls not being set to a datasource. I have some controls bound to a table such as Staff that feeds the dropdown. Then the choice is stored in the foreign key in the table that feeds the form. For example the combo box is sourced by Staff.StaffID but the choice made by the user is stored in Replicate.StaffID.

I hope this is something I can resolve soon. The guys I"m building this database for are chomping at the bit and I told them I'd hopefully have the problem fixed by the end of the week! So please let me know if there is another way I should be approaching this. Should I maybe have "stacked" subforms that become visible when needed? Would that be easier to code?
Mar 28 '07 #38
NeoPa
32,556 Expert Mod 16PB
Great response Melissa.
Will have to give this some thought.
Can you send me your latest version in the mean-time. This will help me when I'm trying to understand all you've said. It should fill in the context for me. I can forward it on to denburt too, if he expresses a wish to receive it.
Mar 28 '07 #39
AccessIdiot
493 256MB
Much appreciated! Will compact and send along momentarily.
Mar 28 '07 #40
Denburt
1,356 Expert 1GB
I'll be in and out but would be glad to look at it. Anything I can do to help. :)
Mar 28 '07 #41
AccessIdiot
493 256MB
I really REALLY appreciate it. I have sent it to NeoPa and am happy to send it to you if you pm me your email address.

cheers!
Mar 28 '07 #42
NeoPa
32,556 Expert Mod 16PB
Much appreciated! Will compact and send along momentarily.
Marvellous!
I won't get home for a while mind you, but it's good to know it'll be there before I am :D
Mar 28 '07 #43
NeoPa
32,556 Expert Mod 16PB
I'll be in and out but would be glad to look at it. Anything I can do to help. :)
Unless I hear to the contrary, I'll forward it straight on to you as soon as I get in, and on my PC tonight Denburt.
Mar 28 '07 #44
NeoPa
32,556 Expert Mod 16PB
Database forwarded :)
Mar 28 '07 #45
AccessIdiot
493 256MB
Cheers :-)
Mar 28 '07 #46
NeoPa
32,556 Expert Mod 16PB
OK.
How do we proceed from here? Generally we need to consider that setting the value of a bound control will immediately set the .Dirty flag, which is undesirable. Consider showing the value in an unbound field and setting (a possibly invisible) bound control on update of the form's record.
Can you tell us which forms particularly you're looking to work on at the moment, as there are a number to choose from and, although we want a general purpose solution, we will need to work with specifics to get it working and test it.

As a side-issue. You should tell the people who are impatiently chasing you for this database that, in our (my) opinion, the project undertaken is a fairly lengthy one, even for an experienced developer. For a relative newbie, their expectations are entirely unreasonable. You can quote me on that. I think you're actually doing a very good job in the circumstances and I'd employ someone with your attitude and capability. Given a little space in which to mature, I expect you'll make a more than capable database developer in time.
Mar 28 '07 #47
AccessIdiot
493 256MB
OK.
How do we proceed from here? Generally we need to consider that setting the value of a bound control will immediately set the .Dirty flag, which is undesirable. Consider showing the value in an unbound field and setting (a possibly invisible) bound control on update of the form's record.
Can you tell us which forms particularly you're looking to work on at the moment, as there are a number to choose from and, although we want a general purpose solution, we will need to work with specifics to get it working and test it.

As a side-issue. You should tell the people who are impatiently chasing you for this database that, in our (my) opinion, the project undertaken is a fairly lengthy one, even for an experienced developer. For a relative newbie, their expectations are entirely unreasonable. You can quote me on that. I think you're actually doing a very good job in the circumstances and I'd employ someone with your attitude and capability. Given a little space in which to mature, I expect you'll make a more than capable database developer in time.

People are chasing me? You'd hire me? what? lol - I think you have me confused with someone capable.

Is it really that difficult? If so I don't want to tackle this problem and wish for a work around. Where is the work around fairy when you need her? Please wave your magic wand!

Okay. So really the only thing I'd like to make happen here is to link the Replicate and Specimen tables. Right now there is a Replicate_ID in tbl_Specimen_Replicate as a foreign key (this also holds true for Entrainment_ID in tbl_Specimen_Entrainment; whatever we get to work for Replicate_ID I'm sure I can apply to Entrainment_ID).

Because you can have multiple Specimens for one Replicate, any time the Specimen form is launched (from the Replicate subform) it needs to know what Replicate the user was on so that it can store the correct Replicate_ID in the Specimen table.

Does that make sense?

I like the idea of bringing the value into an unbound textbox (already done using OpenArgs and works great) and setting the value to a bound control after form update (have tried this multiple ways and can't get it to work so I must be doing something wrong).

To keep my busy I've started playing with a copy of the database using tabs. I was wondering if it would be better/easier to have in the Replicate subform two tabs: one for replicate information and one for specimen information. Do you think this is a good idea? I know nothing about tabs and so am unsure if when you have tabs you have to fill out info on both to create a record or not.

thanks for any and all ideas.
Mar 28 '07 #48
NeoPa
32,556 Expert Mod 16PB
People are chasing me? You'd hire me? what? lol - I think you have me confused with someone capable.
I'm referring to your last paragraph in post #38. Maybe you just meant they're waiting in eager anticipation.
You'd be surprised at how many otherwise intelligent people don't have the 'can do' attitude you show - and the understanding of the importance of understanding what you're doing. I'm forever fixing fixes which are bodged in by others to avoid getting to the seat of the problem.
Is it really that difficult? If so I don't want to tackle this problem and wish for a work around. Where is the work around fairy when you need her? Please wave your magic wand!
I actually doubt you'll get too stuck on this. We'll see.
Okay. So really the only thing I'd like to make happen here is to link the Replicate and Specimen tables. Right now there is a Replicate_ID in tbl_Specimen_Replicate as a foreign key (this also holds true for Entrainment_ID in tbl_Specimen_Entrainment; whatever we get to work for Replicate_ID I'm sure I can apply to Entrainment_ID).

Because you can have multiple Specimens for one Replicate, any time the Specimen form is launched (from the Replicate subform) it needs to know what Replicate the user was on so that it can store the correct Replicate_ID in the Specimen table.

Does that make sense?
Sort of.
We need to be clear what we're referring to though. Are you talking about forms or tables? They are not so closely connected that mixing them up is easily understood. I thought we were working on forms.
I like the idea of bringing the value into an unbound textbox (already done using OpenArgs and works great) and setting the value to a bound control after form update (have tried this multiple ways and can't get it to work so I must be doing something wrong).
Tell me where is the code you've tried in the db sent to me and I'll look in more detail.
To keep myself busy I've started playing with a copy of the database using tabs. I was wondering if it would be better/easier to have in the Replicate subform two tabs: one for replicate information and one for specimen information. Do you think this is a good idea? I know nothing about tabs and so am unsure if when you have tabs you have to fill out info on both to create a record or not.

thanks for any and all ideas.
I can't help much here I'm afraid. If truth be told this is all quite new to me too. I'm just trying to work my way through it with you. It's a good learning experience for me too.
Mar 28 '07 #49
AccessIdiot
493 256MB
Tell me where is the code you've tried in the db sent to me and I'll look in more detail.
Yep I agree it's easy to get forms and tables mixed up so I'm going to be extra careful here.

If you open in design view frm_Survey you'll see in the lower half sbfrm_Replicate (I guess you could just as easily open sbfrm_Replicate). In the bottom left corner is a text field. The text field is called Replicate_ID and the control source is tbl_Replicate.Replicate_ID. This is the primary key of tbl_Replicate. You will also notice a button that says "Add Specimen Information". This has an OnClick event associated with it that launches frm_Specimen. There is some additional code on it that was suggested through this thread such as DoCmd.RunCommand and Debug.Print so I'm not sure if that is still needed or not. The OpenForm command has the Replicate_ID passed as OpenArgs.

Now open frm_Specimen_Replicate in design view. On the right hand side below the combo boxes is an unbound textbox that has the name txt_ReplicateID. On the form itself there is an OnOpen event that passes the OpenArgs value to the textbox. I was playing around yesterday and messed up the code. Right now it reads
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)                                        'Pass replicate id when form opens
  2. If Not IsNull(Me.OpenArgs) Then
  3.          Me.ReplicateID = Me.OpenArgs
  4. End If
  5. End Sub
Please change that to Me.txt_ReplicateID and it will pass the value to the unbound textbox. Below the unbound textbox is another textbox called ReplicateID. I was playing around with the Control Source of this box and right now I believe it is set to tbl_Specimen_Replicate.Replicate_ID.

When in sbfrm_Replicate I need whatever Replicate_ID the user is currently on to be passed to frm_Specimen when they click on the "Add Specimen Information" button. The two Replicate_IDs are linked in a one to many relationship. Not just passed to the form but entered into the tables that underlie the forms so that the data in tbl_Specimen_Replicate is linked to tbl_Replicate by the Replicate_ID.

I hope this makes sense!

Help me Obi Wan NeoPa! You're my only hope!

:-)
Mar 28 '07 #50

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

Similar topics

7
by: John | last post by:
How do I prevent blank data from being entered into a table? For instance, the user fills out a form, but if a field is left blank, then the entire entry won't be filled in. This isn't...
2
by: Josh Strickland | last post by:
I am attempting to create an Access database which uses forms to enter data. The issue I am having is returning the query results from the Stored Procedure back in to the Access Form. ...
10
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address,...
3
by: Saket Mundra | last post by:
I have multiple web forms in my application. The user after logging on is directed to form1 where he enters information desired. Once finished he is directed to form2 and the same procedure goes on...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
23
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of...
2
by: seltzer | last post by:
I am using Access 2000 but I also have the 2003 version. I am working on creating a data entry form in Access for a research study. Since there is a maximum of 255 fields per table in Access, I...
4
by: banderson | last post by:
Hello, I am having a problem getting a new record in a subform to append to the underlying table. When I add a new record to the main form, the subform is blank, except for the ID field, which is...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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,...

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.