Nate
Nate

Reputation: 87

Open a C# form (.dll) with VBA (Access 2010)

I have a simple "login" screen in C# where the user will press Login and another window pops up saying welcome and is working when I build/run on Visual Studio.

Here is the code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Login_Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Welcome");
            this.Close();
        }
    }
}

I also have a VBA form (Access 2010) where a user will click a button, then the C# form should pop up and in the future, instead of saying "welcome" it will redirect to a different form in Access.

Here is the code for the VBA button:

Private Sub Command284_Click()
    Dim objLog As Login_Test.Form1
    Set objLog = New Login_Test.Form1
End Sub

I have made the .dll, .tlb, used regasm on it, and referenced it on Access.

I get: "runtime error 429 activex component can't create object" when pressing the button.

Am I missing something?

Upvotes: 0

Views: 245

Answers (1)

cyboashu
cyboashu

Reputation: 10443

Launch developer command prompt in Admin mode, run this synatx:

regasm.exe Login_Test.dll /tlb /CodeBase

You can keep Login_test.dll anywhere, just provide the full path in command.

Upvotes: 1

Related Questions