recordset "over" 2 forms

I think this is a rather basic question and difficult to explain, but 
I'll try

I have this form with 1 entryfield and 1 puhbutton
In this entryfield I enter a name, or part of a name
I click the pushbutton and another form opens, based upon what I entered 
in the first form
The code for the pushbutton of the first form is:

Private Sub Knop13_Click()
If IsNull(Me!Naam_lk) = False Then
     If MsgBox("Je koos een naam", vbOKOnly, "Let op") Then
     End If
End If

If IsNull(Me!Naam_lk) = False Then
     Dim g As Form, f As Form
     Dim db As Database
     Set db = CurrentDb()
     Dim tb As Recordset
     Dim sql As String
     Set g = Forms![Selectie]
         DoCmd.OpenForm ("leerkrachten")
         Set f = Forms![leerkrachten]
         sql = "SELECT leerkrachten.* FROM leerkrachten WHERE 
leerkrachten.NAAM= '" & Replace(g!Naam_lk, "'", "''") & "' ;"
         Set tb = db.OpenRecordset(sql)
         If tb.RecordCount = 0 Then
             sql = "SELECT leerkrachten.* FROM leerkrachten WHERE 
leerkrachten.Naam Like '" & "*" & Replace(g!Naam_lk, "'", "''") & "*" & "';"
             Set tb = db.OpenRecordset(sql)
         End If
         f!nm_lk = tb!naam
         f!str_lk = tb!straat
         f!gem_lk = tb!plaats
         f!Geb_lk = tb!geboortedatum
         f!PN_lk = tb!postnummer
         f!GSM_lk = tb!GSM
         f!mail_lk = tb!Email
         f!Synd_lk = tb!gesyndiceerd
         f!Nu_lk = tb![Nu nog actief]
     End If
End Sub

(I'm sure this code can be a lot better so any comment is welcome)

The newly opened form is called "leerkrachten"
Everything works just fine.
On this second form I created a pushbutton to navigate through the 
recordset I created through the code above
But, when I click the pushbutton nothing happens... i have the idea I 
"lost" the recordset

What am I doing wrong and how to solve this problem
Thanks you all

JP
0
Jean
1/16/2008 8:30:36 PM
access.formscoding 7493 articles. 0 followers. Follow

3 Replies
593 Views

Similar Articles

[PageSpeed] 53

I think I have a very simple solution. All you have to do is to pass 
"g!Naam_lk" to the second form with the OpenArgs. You could then create the 
record set in the event of your choice in your second form. 

If you are not sure how to use OpenArgs, it is easy to find help on this in 
MS Access built in help.
-- 
Yanick


"Jean-Paul" wrote:

> I think this is a rather basic question and difficult to explain, but 
> I'll try
> 
> I have this form with 1 entryfield and 1 puhbutton
> In this entryfield I enter a name, or part of a name
> I click the pushbutton and another form opens, based upon what I entered 
> in the first form
> The code for the pushbutton of the first form is:
> 
> Private Sub Knop13_Click()
> If IsNull(Me!Naam_lk) = False Then
>      If MsgBox("Je koos een naam", vbOKOnly, "Let op") Then
>      End If
> End If
> 
> If IsNull(Me!Naam_lk) = False Then
>      Dim g As Form, f As Form
>      Dim db As Database
>      Set db = CurrentDb()
>      Dim tb As Recordset
>      Dim sql As String
>      Set g = Forms![Selectie]
>          DoCmd.OpenForm ("leerkrachten")
>          Set f = Forms![leerkrachten]
>          sql = "SELECT leerkrachten.* FROM leerkrachten WHERE 
> leerkrachten.NAAM= '" & Replace(g!Naam_lk, "'", "''") & "' ;"
>          Set tb = db.OpenRecordset(sql)
>          If tb.RecordCount = 0 Then
>              sql = "SELECT leerkrachten.* FROM leerkrachten WHERE 
> leerkrachten.Naam Like '" & "*" & Replace(g!Naam_lk, "'", "''") & "*" & "';"
>              Set tb = db.OpenRecordset(sql)
>          End If
>          f!nm_lk = tb!naam
>          f!str_lk = tb!straat
>          f!gem_lk = tb!plaats
>          f!Geb_lk = tb!geboortedatum
>          f!PN_lk = tb!postnummer
>          f!GSM_lk = tb!GSM
>          f!mail_lk = tb!Email
>          f!Synd_lk = tb!gesyndiceerd
>          f!Nu_lk = tb![Nu nog actief]
>      End If
> End Sub
> 
> (I'm sure this code can be a lot better so any comment is welcome)
> 
> The newly opened form is called "leerkrachten"
> Everything works just fine.
> On this second form I created a pushbutton to navigate through the 
> recordset I created through the code above
> But, when I click the pushbutton nothing happens... i have the idea I 
> "lost" the recordset
> 
> What am I doing wrong and how to solve this problem
> Thanks you all
> 
> JP
> 
0
Utf
1/16/2008 8:46:01 PM
Thanks for the help...
I entered "OpenArgs" in the help... nothing found...
Your solution isn't very clear to me (sorry)
Any help is welcome
JP

Yanick wrote:
> I think I have a very simple solution. All you have to do is to pass 
> "g!Naam_lk" to the second form with the OpenArgs. You could then create the 
> record set in the event of your choice in your second form. 
> 
> If you are not sure how to use OpenArgs, it is easy to find help on this in 
> MS Access built in help.
0
Jean
1/16/2008 9:23:34 PM
The last parameter of the "docmd.openform" function is the OpenArgs. This 
parameter can ben use to send information to the form you want to open. 

You can then send information to build your recordset through the OpenArgs. 

The in the FormLoad event of the form you open you can simply say :

StrVar = OpenArgs

Then build your query. 

If you search for OpenArgs in this newsgroup you will find many results.


-- 
Yanick


"Jean-Paul" wrote:

> Thanks for the help...
> I entered "OpenArgs" in the help... nothing found...
> Your solution isn't very clear to me (sorry)
> Any help is welcome
> JP
> 
> Yanick wrote:
> > I think I have a very simple solution. All you have to do is to pass 
> > "g!Naam_lk" to the second form with the OpenArgs. You could then create the 
> > record set in the event of your choice in your second form. 
> > 
> > If you are not sure how to use OpenArgs, it is easy to find help on this in 
> > MS Access built in help.
> 
0
Utf
1/17/2008 1:42:01 PM
Reply:

Similar Artilces:

How can I flow a music score over 2 pages in Publisher?
Our church secretary needs to paste in music from another source over 2 pages in Publisher. It's no problem to flow text, but how do you flow graphics? You can't. You will have to split the graphic into pieces. -- JoAnn Paules MVP Microsoft [Publisher] "Barb Andersen" <Barb Andersen@discussions.microsoft.com> wrote in message news:69B6964B-FDE3-409E-B8F8-3AB89DE4C52D@microsoft.com... > Our church secretary needs to paste in music from another source over 2 > pages > in Publisher. It's no problem to flow text, but how do you flow graphics? Barb...

recovering outlook files #2
Hi there...I recently had to re-format my hard drive. I tried to back up all my outlook files -- thought I did -- now I can't find my old e-mails & contacts. If I did it right...where would I look in the Office files? Any ideas? Thank you. -- Mary Take a look here, it may help: http://www.slipstick.com/config/backup.htm --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and fi...

Removing overlap of bars when 2 Y axes are used
I made a chart with a secondary Y axis because my two data series had very different scales. This automatically overlapped the two data series bars so that not all of them are visible now (when I had them on one Y axis, distinct bars were present). I have tried to play with the "overlap" option, but it barely separates the bars -more than 90% overlap remains-, I cannot get them to be side by side. I do not want to make one or both series appear as lines. Thanks for any answer. PP74, I believe Jon Peltier's site has an example that you can use. You may need to adjust the...

Outlook 2003 Using over 2 GB of memory
Ok, I have been using Outlook 2003 for a while now and have had an odd problem for a while. If I leave outlook open for a long time, it will consume all of of my free memory. I am talking about 700-800 MB of actual memory, and 1.5 - 1.7 GB of my virtual memory by just leaving it open over night, and this repeats as many times as I leave it open. I have restarted the computer, and no luck. Now it is also happening with my laptop, and I am not sure where to go with this. Any Ideas? Do you have a desktop search program installed? --� Milly Staples [MVP - Outlook] Post all replies to the gro...

how to overlap 2 graphs/2 scales to relay information
I have 2 graphs, one with sales, and the other with service times, i need a way to display results on one graph. You could use the custom Charts and select the line chart on 2 axis. This way you can plot two series of data that have different values on the same chart. best way is to just give it a go. -- infojmac ------------------------------------------------------------------------ infojmac's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=10787 View this thread: http://www.excelforum.com/showthread.php?threadid=543725 ...

How can I discover who accessed Exchange 5.5 server with Outlook 2
I have an Exchange 5.5 server that has been accessed by someone with an Outlook 2003 client. This has caused OWA to stop working. How can I discover which mailbox has been accessed by the Outlook 2003 client? Regards When you look at the Logons information under the Private infomration store, it should show the last time they were accessed, and should also display which client accessed the mailbox. Outlook 2003 should show a client version of 11.0 Also, to be fair, this is a very well known issue, and the hotfix has been available for a long time. The KB article was published back ...

Over 2 GB PST
Eventhough 700MB of .pst files were archived a week ago, my Outlook crashed due to Oversized PST. I ran the 2 GB Truncation Tool three times to reduce the size, first one at 25MB, second at 105MB and the third at 500MB, all three failed when going through the "Inbox Repair Tool" scan. The following error message popped up; "An error has occurred which caused the scan to be stopped. No changes have been made to the scanned file." There was also an error report added to the file holding my truncated .pst file. There are two errors that I think the log is trying to...

How do I make a timesheet add-up 2 shifts a day over 2 weeks?
I'm a bus driver. I want to keep track of my hours, and minutes for my own records, in Excel. Here is an example... Monday; 5:55am - 9:00am & 2:33pm - 5:33pm = 3hrs, 5min. + 3hrs, 0min. = 6hrs,5min. Tuesday; 6:00am - 9:00am & 2:33pm - 5:33pm = 3hrs, 5min. + 3hrs, 0min. = 6hrs,0min. So for those 2 days, so far I'd have 12hrs, 5minutes, times $11.00 an hr. = (about $132) My main idea is to even add up the minutes everyday, because they add up to dollars at the end of 2 weeks. I need to know how to add together 2 shifts everyday over a 2 week period, using hours, an...

Problem getting RPC over HTTP to work. #2
Setup: Two front-end NLB OWA servers with Exch 2003 SP1. Clustered back-end servers with Exch 2003 SP1. Global catalog on seperate server. I've tested the connection from the outside to the https://webmail.domain.com/rpc and it connects as it should. I followed all the steps in the following document and I'm still have connection problems but there is a question that I have in part of this document- http://support.microsoft.com/kb/827330/. Step 8: Verify the Exchange 2003 port configuration. I ran rpcdump /s exchangeserver.domain.com /v /i. The exchangeserver.domain.com is the back ...

RPC Over HTPPS on FE Server with OWA #2
Hi, I have a front end owa server configured as a OWA server using SSL (with a custom made certificate). Can I also utilise this server and the same certificate to make it run rpc over https as well? Thanks in advance. ...

Disaster recovery #2
Hello all Recently my old NT 4 server croaked (running Exchange 5.0)...anyway to cut a long story short, I have the hard drive from the old server up and can access all the old files. I wish to migrate some information such as old emails and contact lists to the new Exchange 2003 server...but I don't know how to do so Any Ideas Thanks Paul Car Network Administrato Managing Foods, LLC. You likely need to rebuild the Exchange 5.0 server and Exmerge the data. -- Hope that helps, Dan Townsend This posting is provided "AS IS" with no warranties, and confers no rights. Please d...

OWA over SSL #2
Hello, I have OWA 5.5 with Exchange 5.5 mailbox server, OWA with SSL certificate installed. If I were to re-install OWA, would I lose the certificate? As long as you have the original certs and use the same domain name, you should be able to reinstall the certs in IIS without a problem. -EricL "MAX" wrote: > Hello, > I have OWA 5.5 with Exchange 5.5 mailbox server, OWA with SSL certificate > installed. If I were to re-install OWA, would I lose the certificate? ...

recordset "over" 2 forms
I think this is a rather basic question and difficult to explain, but I'll try I have this form with 1 entryfield and 1 puhbutton In this entryfield I enter a name, or part of a name I click the pushbutton and another form opens, based upon what I entered in the first form The code for the pushbutton of the first form is: Private Sub Knop13_Click() If IsNull(Me!Naam_lk) = False Then If MsgBox("Je koos een naam", vbOKOnly, "Let op") Then End If End If If IsNull(Me!Naam_lk) = False Then Dim g As Form, f As Form Dim db As Database Set db = Cur...

recover deleted mailbox #2
Hi all. I have accidentally delete and purge my mailbox. I tried to recover it using nt backup and recovery storage group. In the mailbox store of my recovery storage group i can see all the mailboxes that were backup which include the 1 i accidentally deleted. However when i try to merge the mailbox that i accidentally deleted back to my main mailbox store under the first storage group, the process failed. Any suggestion on how i can restore it? Thks in advance. inenewbl <inenewbl@discussions.microsoft.com> wrote: > Hi all. I have accidentally delete and purge my mailbox. I tr...

All Day events cover 2 day
When I create an all day event or even an event that covers several days, it looks fine in monthly view if you look at it in a list view it spans over to two days. So when you sync your calendar your pda shows the event as 2 days. The default for an all day event is 12:00 am to 12:00 am is there a style sheet that can be changed to reflect an all day event to be 23 hours and 59 mins. Add the duration field to the view and you'll see they are only 1 day. If they spread over 2 days on the pda, check the time zone settings on the pda. -- Diane Poremsky [MVP - Outlook] Out...

Just invest $ 2 to make $2 over and over??
Yes it's possible! Do you think its a scam> No Way, coz scammers would want a hefty amount of 20-30 dollars! from each person, here u pay initially only$2.4 from Paypal! Join fast .... http://www.twodollars.biz/?a=534283 ...

Recovering Deleted Items #2
Hi, My V.P. is getting an error ( "outlook has generated an error and the application will close") when he is trying to recover a deleted item.No other messages or errors come up. Then Outlook shuts down. The deleted items window does come up but when you click on an item to recover,this error comes up.We are using Outlook 2000. I have been unable to find anything referencing this issue and was wondering if anybody could assist me with this....Thanks Continue at original threat instead of reposting! -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the mont...

Change overlap of 2 columns on 2 axes
I am trying to plot 2 columns of data on the same X-axis but on 2 Y-axis plots. But the columns are overlapping and I can't see one set of data. I don't want them stacked and changing the gap and overlap width doesn't seem to do anything. Suggestions? Hi, You need to add 2 dummy series to act as place holders. Example data set in range A1:E4 B1: =Left C1: =DumRight D1: =DumLeft E1:=Right A2: =One B2: =1 C2: =0 D2: =0 E2: =3 A3: =Two B3: =2 C3: =0 D3: =0 E3: =2 A4: =Four B4: =3 C4: =0 D4: =0 E4: =1 ...

Network discovery #2
We are thinking of buying Visio 2003 Pro and it's resource kit. The resource kit is supposed to contain a program that will probe and discover the network. Have you used this feature ? the network discovery in the resource kit (the fluke tool) is for small single site. al "Jerry" <jerry@mwex.com> wrote in message news:esJ$T5gjFHA.3348@tk2msftngp13.phx.gbl... > We are thinking of buying Visio 2003 Pro and it's resource kit. The > resource kit is supposed to contain a program that will probe and discover > the network. Have you used this feature ...

Password Recovery #2
Could anyone provide links to password recovery devices similar to allinternalpasswords.xls and/or password.xla but for MS ACCESS or WORD? Thanks for previous help with the Excel Files I am attempting to gain access to files paid for by my client [to a previous consulting firm] but some key files were passworded and therefore not usable by my client. The former consulting firm employed a subcontractor who was supposed to leave all files accessable but obviously did not. No one can find the subcontractor. Have you tried a Google search for "password recovery"? This will tak...

Recovery #2
Sir, In our test Exchange Server, there are three mailbox stores, Employees -- first mailbox store Management --> Second Mail Store and a public folder employees mail store --> Employees.edb & Employees.stm Files Got corrupted. Employees mailbox store not mounting Pls send me the procedures for recoverying and mounting the mailbox store using ntbackup Thanks and Regards Sathish Kumar Nair On Tue, 16 Aug 2005 07:55:04 -0700, sathish kumar nair <sathishkumarnair@discussions.microsoft.com> wrote: >Sir, > >In our test Exchange Server, there are three mailbox st...

VC++ 7.1 Stack Overflow #2
I am using Microsoft Visual C++ 7.1 on Windows XP. I get a stack overflow at test dword ptr [ecx],eax ; ...probe it in chkstk.asm but there is no recursion. I get this apparent stack overflow with the following call stack _____________________________________________________________________________ > ProgName.exe!_chkstk() Line 91 Asm ProgName.exe!CThreeD::GetPoints(FloatPlane_Struct * fppInputPlanes=0x0147fee8, int bAlignPlanes=1) Line 61 + 0x14 C++ ProgName.exe!CProgNameApp::GetControlPoints(char * * cspNameBuffer=0x019caf68, long lNumberOfDocumentsSelected=2, long * lpS...

rcp over http #2
Hello, I have an exchange 2003 standard std with sp2 in a costumer, that that configured as rcp over http the question is the following one, from the company (not from the client), I configure the outlook 2003 to use it but it doesn't allow me the connection, the managerial firewall only allows me the ports of out 80 and 443. It is necessary to open some more. -From my house it works correctly. thanks On Thu, 28 Sep 2006 12:14:00 +0200, "Miguel" <miguel.romero78@gmail.com> wrote: >Hello, > >I have an exchange 2003 standard std with sp2 in a costumer, t...

Ability 2 put * over single bar in graph 2 indicate stat sig
To indicated statistical significance in academic publishing we often place a character (e.g. *) above a single bar in a graph. Currently one uses a text box which moves and isn't the best. Make sure the character can be changed with respect to size and intentisty. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and...

MSCRM 1.2 Installed over companyweb
I installed MSCRM on SBS 2003 and the website installed over companyweb (Sharepoint site), how do I get this back? Hi McKenzie, There is no easy way of going back. The easiest would be to restore a backup if you do make those. Otherwise you will need to backup your data in the sharepoint databases and reinstall SBS. Lets hope you did make backups :) Kind regards, Ronald Lemmen Avanade Netherlands "McKenzie" wrote: > I installed MSCRM on SBS 2003 and the website installed over companyweb > (Sharepoint site), how do I get this back? If I am not mistaken you can find...