Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Databases on multiple forms

I need to use a database on multiple forms. Well, I put my data control down, and it does what I want it to on the first form. Here is how I did it:


Private mrstATMDatabase As Recordset


Set grstATMDatabase = datAccounts.Recordset



Dim pstrName As String

pstrName = txtUserName.Text



'Searches the database for the name

grstATMDatabase.FindFirst "Name = " & "'" & _

pstrName & "'"


It works great on the initial form, but on the later forms, I use the same syntax, and i even cut and paste the same data control. On the later forms, I always get the Object variable or With Block variable not set error. At first I thought it was syntax, but it is correct. I can't seem to figure out this problem.


Comments

  • : I need to use a database on multiple forms. Well, I put my data control down, and it does what I want it to on the first form. Here is how I did it:


    : Private mrstATMDatabase As Recordset


    : Set grstATMDatabase = datAccounts.Recordset

    :

    : Dim pstrName As String

    : pstrName = txtUserName.Text

    :

    : 'Searches the database for the name

    : grstATMDatabase.FindFirst "Name = " & "'" & _

    : pstrName & "'"


    : It works great on the initial form, but on the later forms, I use the same syntax, and i even cut and paste the same data control. On the later forms, I always get the Object variable or With Block variable not set error. At first I thought it was syntax, but it is correct. I can't seem to figure out this problem.


    I may be wrong but you may have to close the database.


    grstATMDatabase.close


    That may not be the prob but its worth trying i guess :)


    Chris Andersen




  • I think the problem might be that I was told that I could not use a golbal Recordset on multipule form, with only one datacontrol on an initial form. I am still used to programming in a more complex landuage


    : I need to use a database on multiple forms. Well, I put my data control down, and it does what I want it to on the first form. Here is how I did it:


    : Private mrstATMDatabase As Recordset


    : Set grstATMDatabase = datAccounts.Recordset

    :

    : Dim pstrName As String

    : pstrName = txtUserName.Text

    :

    : 'Searches the database for the name

    : grstATMDatabase.FindFirst "Name = " & "'" & _

    : pstrName & "'"


    : It works great on the initial form, but on the later forms, I use the same syntax, and i even cut and paste the same data control. On the later forms, I always get the Object variable or With Block variable not set error. At first I thought it was syntax, but it is correct. I can't seem to figure out this problem.





  • Andre YoungAndre Young USAMember Posts: 0

    _____ || http://forcoder.org || free ebooks and video tutorials about \ Perl, Go, Visual Basic .NET, C++, Delphi, Ruby, C#, R, C, PL/SQL, PHP, MATLAB, Objective-C, Java, Visual Basic, Swift, JavaScript, Scratch, Python, Assembly Prolog, Dart, LabVIEW, ABAP, Apex, D, Bash, Scala, Fortran, Transact-SQL, Lisp, Lua, SAS, Alice, Erlang, Julia, ML, Logo, COBOL, Ada, VBScript, Hack, Awk, Kotlin, Scheme, Rust, Crystal, FoxPro, Clojure, F# \ _

Sign In or Register to comment.